//
//  Customers.m
//  A One POS
//
//  Created by AonePOS on 24/09/13.
//  Copyright (c) 2013 AonePOS. All rights reserved.
//

#import "Customers.h"
#import "Customerpagination.h"
#import "Settings.h"
#import "Home.h"
#import "Profile.h"
#import "Inventory.h"
#import "Stores.h"
#import "Employees.h"
#import "Reports.h"
#import "Contacts.h"
#import "DataBaseManager.h"
#import "ServersyncClass.h"
#define SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(v)  ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] != NSOrderedAscending)
@interface Customers ()

@end

@implementation Customers
{
    NSString *customerNO;
    ServersyncClass *serverSyncClassObject;
     general_data *generalDataObject;
    Customerpagination *customerPaginationObject;
    
}
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
    }
    return self;
}

- (void)viewDidLoad
{
    generalDataObject =[general_data new];
    [generalDataObject  GetuserDataVariablesMethod];
   
    serverSyncClassObject=[ServersyncClass new];
    customerPaginationObject =[Customerpagination new];
    [NSThread detachNewThreadSelector:@selector(ServerSyncronizationMethod) toTarget:serverSyncClassObject withObject:nil];
      //appDelegate =  (AppDelegate *)[UIApplication sharedApplication].delegate;
    [super viewDidLoad];
    //[NSThread detachNewThreadSelector:@selector(ServerSyncronizationMethod) toTarget:[ServersyncClass sharedInstance] withObject:nil];
    y=0;
    if (SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(@"7.0"))
    {
        y=y+20;
        
        
    }
    CGFloat width,height;
    width=self.view.frame.size.width;
    height=self.view.frame.size.height;
    // //NSLog(@" %f,%f",width,height);
    
    
    
    backgroundcolorview=[[UIView alloc]init];
    backgroundcolorview.frame=CGRectMake(0,y,width,height-100);
    [backgroundcolorview  setBackgroundColor:[UIColor colorWithPatternImage:[[UIImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"background" ofType:@"jpg"]]]];
    
    [self.view addSubview:backgroundcolorview];
    
    // [ContactsBtn setImage:[[UIImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"contactsactive" ofType:@"png"]] forState:UIControlStateNormal];
    
    sidemenu=[[UIView alloc]init];
    sidemenu.frame=CGRectMake(0, 1,170 ,height-150);
    //sidemenu.hidden=YES;
    //[sidemenu  setBackgroundColor:[UIColor colorWithPatternImage:[UIImage imageNamed:@"bluecolorstrip.jpg"]]];
    [sidemenu  setBackgroundColor:[UIColor colorWithPatternImage:[[UIImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"bluecolorstrip" ofType:@"jpg"]]]];
    
    
    NSString *pagetitle;
    pagetitle=@"Customer";
    
    
    
    navBar = [[UINavigationBar alloc] init];
    navBar.frame=CGRectMake(0, 0,width , 50.0);
    
    [navBar setBackgroundImage:[UIImage imageNamed:@"logo-login-bg-short.png"] forBarMetrics:UIBarMetricsDefault];
    
    //[navBar setBackgroundColor:[UIColor blackColor]];
    UILabel *titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 100, 50)];
    titleLabel.font=[UIFont boldSystemFontOfSize:30.0];
    titleLabel.textColor = [UIColor blackColor];
    titleLabel.backgroundColor = [UIColor clearColor];
    titleLabel.text =pagetitle;
    [self.navigationItem setTitleView:titleLabel];
    
    
    //navItem.title = pagetitle;
    [navBar pushNavigationItem:self.navigationItem animated:false];
    
    [backgroundcolorview addSubview:navBar];
    
    
    menubutton = [UIButton buttonWithType:UIButtonTypeCustom];
    [menubutton setFrame:CGRectMake(0,0,50,50)];
    [menubutton addTarget:self action:@selector(menuclicked) forControlEvents:UIControlEventTouchUpInside];
    
    [menubutton setImage:[[UIImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"arrow" ofType:@"png"]] forState:UIControlStateNormal];
    [navBar addSubview:menubutton];
    
    
    logoBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    [logoBtn setFrame:CGRectMake(60,0,250,50)];
    // [logoBtn addTarget:self action:@selector(menuclicked) forControlEvents:UIControlEventTouchUpInside];
    
    //[logoBtn setImage:[UIImage imageNamed:@"headeraonelogo.png"] forState:UIControlStateNormal];
    [logoBtn setImage:[[UIImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"headeraonelogo" ofType:@"png"]] forState:UIControlStateNormal];
    
    [navBar addSubview:logoBtn];
    sationLbl=[[UILabel alloc] init];
    
    sationLbl.frame=CGRectMake(navBar.frame.size.width-280, 5,100, 40);
    
    [sationLbl setFont:[UIFont systemFontOfSize:13.0f]];
    [sationLbl setBackgroundColor:[UIColor clearColor]];
    [sationLbl setTextColor:[UIColor blackColor]];
    [sationLbl setText:@"Station No:1"];
    sationLbl.lineBreakMode = NSLineBreakByWordWrapping;
    sationLbl.numberOfLines = 2;
    [sationLbl setTextAlignment:NSTextAlignmentLeft];
    [navBar addSubview:sationLbl];
    
    
    EmpIdlbl=[[UILabel alloc] init];
    EmpIdlbl.frame=CGRectMake(navBar.frame.size.width-193, 5,150, 40);
    
    [EmpIdlbl setFont:[UIFont systemFontOfSize:13.0f]];
    [EmpIdlbl setBackgroundColor:[UIColor clearColor]];
    [EmpIdlbl setTextColor:[UIColor blackColor]];
    [EmpIdlbl setText:[NSString stringWithFormat:@"Employee Id: %@",[generalDataObject  userID]]];
    EmpIdlbl.lineBreakMode = NSLineBreakByWordWrapping;
    // EmpIdlbl.numberOfLines = 2;
    [EmpIdlbl setTextAlignment:NSTextAlignmentLeft];
    [navBar addSubview:EmpIdlbl];
    
    
    Timelbl=[[UILabel alloc] init];
    
    Timelbl.frame=CGRectMake(navBar.frame.size.width-62, 6,80, 40);
    
    [Timelbl setFont:[UIFont systemFontOfSize:13.0f]];
    [Timelbl setBackgroundColor:[UIColor clearColor]];
    [Timelbl setTextColor:[UIColor blackColor]];
    NSDate *aDate = [NSDate date];
    NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
    [formatter setDateStyle:NSDateFormatterShortStyle];
    [formatter setTimeStyle:NSDateFormatterNoStyle];
    [formatter setDateFormat:@"HH:mm:ss"];
    NSString *datestr;
    datestr=[formatter stringFromDate:aDate];
    Timelbl.text=datestr;
    //Timelbl.text=[NSString stringWithFormat:@"%@:%@",@"Time",datestr];
    
    // timer is set & will be triggered each second
    //[NSTimer scheduledTimerWithTimeInterval:0.1 target:self selector:@selector(showTime) userInfo:nil repeats:YES];
    Timelbl.lineBreakMode = NSLineBreakByWordWrapping;
    Timelbl.numberOfLines = 2;
    [Timelbl setTextAlignment:NSTextAlignmentLeft];
    [navBar addSubview:Timelbl];
    p=1;
    @autoreleasepool {
        for (int i=0; i< 10; i++)
        {
            
            categorybutton = [UIButton buttonWithType:UIButtonTypeCustom];
            
            [categorybutton setFrame:CGRectMake(0,p,170,40)];
            [categorybutton addTarget:self action:@selector(categotybuttonclicked:) forControlEvents:UIControlEventTouchUpInside];
            categorybutton.tag=i;
            if (categorybutton.tag == 0)
            {
                [categorybutton setImage:[UIImage imageNamed:@"posnormal2.png"] forState:UIControlStateNormal];
            }
            
            else if (categorybutton.tag == 1)
            {
                [categorybutton setImage:[UIImage imageNamed:@"profilenormal2.png"] forState:UIControlStateNormal];
            }
            else if (categorybutton.tag == 2)
            {
                [categorybutton setImage:[UIImage imageNamed:@"inventorynormal2.png"] forState:UIControlStateNormal];
            }
            else if(categorybutton.tag == 3)
            {
                [categorybutton setImage:[UIImage imageNamed:@"customeractive2.png"] forState:UIControlStateNormal];
            }
            else if (categorybutton.tag == 4)
            {
                [categorybutton setImage:[UIImage imageNamed:@"employeenormal2.png"] forState:UIControlStateNormal];
            }
            else if(categorybutton.tag == 5)
            {
                [categorybutton setImage:[UIImage imageNamed:@"settingsnormal2.png"] forState:UIControlStateNormal];
            }
            else if(categorybutton.tag == 6)
            {
                [categorybutton setImage:[UIImage imageNamed:@"reportsnormal2.png"] forState:UIControlStateNormal];
            }
            else if(categorybutton.tag == 7)
            {
                [categorybutton setImage:[UIImage imageNamed:@"contactsnormal2.png"] forState:UIControlStateNormal];
            }
            else if (categorybutton.tag == 8)
            {
                [categorybutton setImage:[UIImage imageNamed:@"storesnormal.png"] forState:UIControlStateNormal];
            }
            
            else if (categorybutton.tag == 9)
            {
                //[categorybutton setImage:[UIImage imageNamed:@"bluecolorstrip.jpg"] forState:UIControlStateNormal];
            }
            [sidemenu addSubview:categorybutton];
            p=p+categorybutton.frame.size.height;
        }

    }
    
    mainview=[[UIView alloc]init];
    mainview.frame=CGRectMake(20,60,width-40,height-200);
    [mainview setBackgroundColor:[UIColor grayColor]];
    [mainview  setBackgroundColor:[UIColor colorWithPatternImage:[UIImage imageNamed:@"hqbackground69opacity.png"]]];
    [backgroundcolorview addSubview:mainview];
    
    logoimageview=[[UIImageView alloc]init];
    logoimageview.frame=CGRectMake(50, (backgroundcolorview.frame.size.height)+5+y,(height-(backgroundcolorview.frame.size.height)-30), (height-(backgroundcolorview.frame.size.height)-30));
    [logoimageview setImage:[[UIImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"aoneposlogo" ofType:@"png"]]];
    [self.view addSubview:logoimageview];
    
    helpiconButton = [UIButton buttonWithType:UIButtonTypeCustom];
    
    [helpiconButton setFrame:CGRectMake(width-180,y+40,70,70)];
    [helpiconButton addTarget:self action:@selector(helpiconclicked) forControlEvents:UIControlEventTouchUpInside];
    
    //[helpiconButton setImage:[UIImage imageNamed:@"helpicon.png"] forState:UIControlStateNormal];
    [helpiconButton setImage:[[UIImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"helpicon" ofType:@"png"]] forState:UIControlStateNormal];
    
    [self.view addSubview:helpiconButton];
    logouticonButton = [UIButton buttonWithType:UIButtonTypeCustom];
    
    [logouticonButton setFrame:CGRectMake(width-100,y+40,70,70)];
    [logouticonButton addTarget:self action:@selector(logoutButtonClicked) forControlEvents:UIControlEventTouchUpInside];
    
    //[logouticonButton setImage:[UIImage imageNamed:@"logoutbutton.png"] forState:UIControlStateNormal];
    [logouticonButton setImage:[[UIImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"logoutbutton" ofType:@"png"]] forState:UIControlStateNormal];
    [self.view addSubview:logouticonButton];
    isLandScope = UIInterfaceOrientationIsLandscape([UIApplication sharedApplication].statusBarOrientation);
    [self updateUI];
    
    
    
    //Customers View
    
    
    CustomersBackView=[[UIView alloc]init];
    CustomersBackView.frame=CGRectMake(10, 0, mainview.frame.size.width-20, (mainview.frame.size.height));
    [CustomersBackView setBackgroundColor:[UIColor whiteColor]];
    [CustomersBackView.layer setBorderWidth: 1.0];
    [CustomersBackView.layer setCornerRadius:8.0f];
    [CustomersBackView.layer setMasksToBounds:YES];
    [CustomersBackView.layer setBorderColor:[[UIColor blackColor] CGColor]];
    
    CustomersBackView.layer.cornerRadius=8;
    [mainview addSubview:CustomersBackView];
    
    AddCustomerBtn=[UIButton buttonWithType:UIButtonTypeCustom];
    [AddCustomerBtn setTitle:@"Add Customer" forState:UIControlStateNormal];
    CGFloat addbuttonwidth=(CustomersBackView.frame.size.width-10)/2;
    AddCustomerBtn.frame=CGRectMake(10, 10, addbuttonwidth, 40);
    [AddCustomerBtn setBackgroundImage:[UIImage imageNamed:@"bluetabactive.png"] forState:UIControlStateNormal];
    
    
    //addtaxBtn.layer.cornerRadius=8;
    [AddCustomerBtn addTarget:self action:@selector(AddCustomer) forControlEvents:UIControlEventTouchUpInside];
    [CustomersBackView addSubview:AddCustomerBtn];
    EditCustomerBtn=[UIButton buttonWithType:UIButtonTypeCustom];
    
    [EditCustomerBtn setTitle:@"View and Edit Customer" forState:UIControlStateNormal];
    EditCustomerBtn.frame=CGRectMake(AddCustomerBtn.frame.size.width, 10, addbuttonwidth, 40);
    //editTaxButton.backgroundColor=[UIColor colorWithRed:203.0f green:203.0f/255.0f blue:203.0f/255.0f alpha:1.0f];
    [EditCustomerBtn setBackgroundColor:[UIColor whiteColor]];
    [EditCustomerBtn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    
    [EditCustomerBtn addTarget:self action:@selector(Editcustomer) forControlEvents:UIControlEventTouchUpInside];
    [CustomersBackView addSubview: EditCustomerBtn];
    
    AddCustomersView=[[UIScrollView alloc]init];
    
    AddCustomersView.frame=CGRectMake(10, AddCustomerBtn.frame.size.height+10, CustomersBackView.frame.size.width-20, CustomersBackView.frame.size.height-20-AddCustomerBtn.frame.size.height);
    [AddCustomersView setBackgroundColor:[UIColor colorWithRed:0.0f green:74.0f/255.0f blue:132.0f/255.0f alpha:1.0f]];
    
    //AddCustomersView.layer.cornerRadius=8;
    [CustomersBackView addSubview:AddCustomersView];
    
    
    CGFloat customerW=(AddCustomersView.frame.size.width)/4;
    CGFloat r=(customerW/2)+20;
    
    CustomerLbl=[[UILabel alloc] init];
    CustomerLbl.frame=CGRectMake(r-80, 30,customerW, 50);
    
    [CustomerLbl setFont:[UIFont systemFontOfSize:25.0f]];
    [CustomerLbl setBackgroundColor:[UIColor clearColor]];
    [CustomerLbl setTextColor:[UIColor whiteColor]];
    [CustomerLbl setText:@"Customer#"];
    CustomerLbl.lineBreakMode = NSLineBreakByWordWrapping;
    CustomerLbl.numberOfLines = 2;
    [CustomerLbl setTextAlignment:NSTextAlignmentLeft];
    [AddCustomersView addSubview:CustomerLbl];
    CustomerField=[[UITextField alloc] init];
    //[nameTextfield setBorderStyle:UITextBorderStyleRoundedRect];
    CustomerField.frame=CGRectMake(customerW-5, 35,customerW, 40);
    CustomerField.delegate=self;
    UIView *paddingview=[[UIView alloc] initWithFrame:CGRectMake(5, 0, 5, 20)];
    // // //NSLog(@"%f",GeneralinfoField.frame.origin.y);
    CustomerField.leftView = paddingview;
    CustomerField.contentVerticalAlignment=UIControlContentVerticalAlignmentCenter;
    CustomerField.leftViewMode = UITextFieldViewModeAlways;
    [CustomerField setBackground:[UIImage imageNamed:@"addinputtextfield.png"]];
    [CustomerField setAutocorrectionType:UITextAutocorrectionTypeNo];
    [AddCustomersView addSubview:CustomerField];
    
    Lastnamelbl=[[UILabel alloc] init];
    Lastnamelbl.frame=CGRectMake(r-80, 100,customerW, 50);
    
    [Lastnamelbl setFont:[UIFont systemFontOfSize:25.0f]];
    [Lastnamelbl setBackgroundColor:[UIColor clearColor]];
    [Lastnamelbl setTextColor:[UIColor whiteColor]];
    [Lastnamelbl setText:@"LastName"];
    Lastnamelbl.lineBreakMode = NSLineBreakByWordWrapping;
    Lastnamelbl.numberOfLines = 2;
    [Lastnamelbl setTextAlignment:NSTextAlignmentLeft];
    [AddCustomersView addSubview:Lastnamelbl];
    
    LastnameField=[[UITextField alloc] init];
    //[nameTextfield setBorderStyle:UITextBorderStyleRoundedRect];
    LastnameField.frame=CGRectMake(customerW-5, 105,customerW, 40);
    LastnameField.delegate=self;
    UIView *paddingview2=[[UIView alloc] initWithFrame:CGRectMake(5, 0, 5, 20)];
    // // //NSLog(@"%f",GeneralinfoField.frame.origin.y);
    LastnameField.leftView = paddingview2;
    LastnameField.contentVerticalAlignment=UIControlContentVerticalAlignmentCenter;
    LastnameField.leftViewMode = UITextFieldViewModeAlways;
    [LastnameField setBackground:[UIImage imageNamed:@"addinputtextfield.png"]];
    [LastnameField setAutocorrectionType:UITextAutocorrectionTypeNo];
    [AddCustomersView addSubview:LastnameField];
    
    
    firstnamelbl=[[UILabel alloc] init];
    firstnamelbl.frame=CGRectMake(customerW+5+LastnameField.frame.size.width+10, 30,customerW, 50);
    
    [firstnamelbl setFont:[UIFont systemFontOfSize:25.0f]];
    [firstnamelbl setBackgroundColor:[UIColor clearColor]];
    [firstnamelbl setTextColor:[UIColor whiteColor]];
    [firstnamelbl setText:@"FirstName"];
    firstnamelbl.lineBreakMode = NSLineBreakByWordWrapping;
    firstnamelbl.numberOfLines = 2;
    [firstnamelbl setTextAlignment:NSTextAlignmentLeft];
    [AddCustomersView addSubview:firstnamelbl];
    
    FirstnameField=[[UITextField alloc] init];
    //[nameTextfield setBorderStyle:UITextBorderStyleRoundedRect];
    FirstnameField.frame=CGRectMake(customerW-15+LastnameField.frame.size.width+firstnamelbl.frame.size.width, 35,customerW, 40);
    FirstnameField.delegate=self;
    UIView *paddingview3=[[UIView alloc] initWithFrame:CGRectMake(5, 0, 5, 20)];
    // // //NSLog(@"%f",GeneralinfoField.frame.origin.y);
    FirstnameField.leftView = paddingview3;
    FirstnameField.contentVerticalAlignment=UIControlContentVerticalAlignmentCenter;
    FirstnameField.leftViewMode = UITextFieldViewModeAlways;
    [FirstnameField setBackground:[UIImage imageNamed:@"addinputtextfield.png"]];
    [FirstnameField setAutocorrectionType:UITextAutocorrectionTypeNo];
    [AddCustomersView addSubview:FirstnameField];
    
    Emaillbl=[[UILabel alloc] init];
    Emaillbl.frame=CGRectMake(customerW+5+LastnameField.frame.size.width+10, 100,customerW, 50);
    
    [Emaillbl setFont:[UIFont systemFontOfSize:25.0f]];
    [Emaillbl setBackgroundColor:[UIColor clearColor]];
    [Emaillbl setTextColor:[UIColor whiteColor]];
    [Emaillbl setText:@"E-mail"];
    Emaillbl.lineBreakMode = NSLineBreakByWordWrapping;
    Emaillbl.numberOfLines = 2;
    [Emaillbl setTextAlignment:NSTextAlignmentLeft];
    [AddCustomersView addSubview:Emaillbl];
    
    EmailField=[[UITextField alloc] init];
    //[nameTextfield setBorderStyle:UITextBorderStyleRoundedRect];
    EmailField.frame=CGRectMake(customerW-15+LastnameField.frame.size.width+firstnamelbl.frame.size.width, 105,customerW, 40);
    EmailField.delegate=self;
    UIView *paddingview4=[[UIView alloc] initWithFrame:CGRectMake(5, 0, 5, 20)];
    // // //NSLog(@"%f",GeneralinfoField.frame.origin.y);
    EmailField.leftView = paddingview4;
    EmailField.contentVerticalAlignment=UIControlContentVerticalAlignmentCenter;
    EmailField.leftViewMode = UITextFieldViewModeAlways;
    EmailField.autocapitalizationType = UITextAutocapitalizationTypeNone;
    [EmailField setBackground:[UIImage imageNamed:@"addinputtextfield.png"]];
    [EmailField setAutocorrectionType:UITextAutocorrectionTypeNo];
    [AddCustomersView addSubview:EmailField];
    NSArray *array2;
    if (!array2)
    array2=[[NSArray alloc]initWithObjects:@"GeneralInfo",@"ExtentedInfo",@"Shipping",@"History",@"Notes",@"Stores",nil];
    CGFloat wdth=(AddCustomersView.frame.size.width)/7;
    CGFloat xvalue=wdth/4;
    for (int k=0; k<6; k++)
    {
        CustomerInfoBtn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
        [CustomerInfoBtn setTitle:[array2 objectAtIndex:k] forState:UIControlStateNormal];
        [CustomerInfoBtn setBackgroundImage:[UIImage imageNamed:@"additionaloptions.png"] forState:UIControlStateNormal];
        CustomerInfoBtn.frame=CGRectMake(xvalue-13,200,wdth+5, 40);
        
        [CustomerInfoBtn addTarget:self action:@selector(infoButton1Clicked:) forControlEvents:UIControlEventTouchUpInside];
        CustomerInfoBtn.tag=k+100;
        [CustomerInfoBtn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
        
        [AddCustomersView addSubview:CustomerInfoBtn];
        xvalue=xvalue+wdth+12;
        
    }
    
    SavecustomerBtn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
    
    SavecustomerBtn.frame=CGRectMake(customerW+100, 300, 80, 30);
    [SavecustomerBtn addTarget:self action:@selector(SaveCustomerData) forControlEvents:UIControlEventTouchUpInside];
    
    //[SaveTaxButton setTitle:@"Save" forState:UIControlStateNormal];
    [SavecustomerBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    [SavecustomerBtn setBackgroundImage:[UIImage imageNamed:@"savegreenbutton.png"] forState:UIControlStateNormal];
    [AddCustomersView addSubview:SavecustomerBtn];
    
    CancelCustomerBtn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
    
    CancelCustomerBtn.frame=CGRectMake(customerW+220, 300, 80, 30);
    [CancelCustomerBtn addTarget:self action:@selector(CancelCustomerData) forControlEvents:UIControlEventTouchUpInside];
    [CancelCustomerBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    [CancelCustomerBtn setBackgroundImage:[UIImage imageNamed:@"cancelgreenbutton.png"] forState:UIControlStateNormal];
    // [CancelTaxButton setTitle:@"Cancel" forState:UIControlStateNormal];
    [AddCustomersView addSubview:CancelCustomerBtn];

    SelectedStoredataArray=[[NSMutableArray alloc]init];

    NSString *querySQL = [NSString stringWithFormat: @"SELECT customer_no,customer_first_name,customer_last_name,customer_email,customer_notes FROM customer_table"];
    NSMutableArray *customersArray=[[NSMutableArray alloc]init];
    [[DataBaseManager dataBaseManager]execute:querySQL resultsArray:customersArray];
    
    NSMutableArray *rdarray=customersArray;
    
    //updateTableArray3=[[NSMutableArray alloc] init];
    
    [customerPaginationObject  setCompleteresultset:rdarray];
    
    [customerPaginationObject   paginationinitializer:rdarray :20];
    
    [customerPaginationObject  paginationsegment].tintColor=[UIColor whiteColor];
    [[customerPaginationObject  paginationsegment] setFrame:CGRectMake(10, AddCustomerBtn.frame.size.height+10,CustomersBackView.frame.size.width-20, 40)];
    
    [[customerPaginationObject  paginationsegment] addTarget:self action:@selector(segmentchanged4:) forControlEvents:UIControlEventValueChanged];
    
    NSInteger selectedsegindex;
    selectedsegindex=0;
    [customerPaginationObject  paginationsegment].selectedSegmentIndex=selectedsegindex;
   [customerPaginationObject  activateResults:selectedsegindex];
    
    EditCustomerTable=[[UITableView alloc]init];
    [EditCustomerTable  setBackgroundColor:[UIColor colorWithRed:0.0f green:74.0f/255.0f blue:132.0f/255.0f alpha:1.0f]];
    EditCustomerTable.frame=CGRectMake(10, AddCustomerBtn.frame.size.height+50, CustomersBackView.frame.size.width-20, CustomersBackView.frame.size.height-20-AddCustomerBtn.frame.size.height-40);

    EditCustomerTable.delegate=self;
    EditCustomerTable.dataSource=self;
    
    [CustomerField setReturnKeyType:UIReturnKeyNext];
    [FirstnameField setReturnKeyType:UIReturnKeyNext];
    [LastnameField setReturnKeyType:UIReturnKeyNext];
    [EmailField setReturnKeyType:UIReturnKeyDone];
    GCompanyName=@"";GStreetAddress=@"";GStreetAddress2=@"";Gstate=@"";Gcity=@"";GCountry=@"";Gphone=@"";GpostalCode=@"";GAlternatePhone=@"";GBirthDay=@"";
    ShCompanyName=@"";ShStreetAddress=@"";ShStreetAddress2=@"";Shstate=@"";Shphone=@"";ShpostalCode=@"";Shcity=@"";ShCountry=@"";ShAlternatePhone=@""; ShBirthDay=@"";
    ExpDate=@"";Expiration=@"";cardType=@"";CardNo=@"";LicenseId=@"";MPhone=@"";Fax=@"";
    // Do any additional setup after loading the view from its nib.
    
     helpiconButton.hidden=YES;
}
-(void)viewWillAppear:(BOOL)animated
{
 
    isLandScope = UIInterfaceOrientationIsLandscape([UIApplication sharedApplication].statusBarOrientation);
    [self updateUI];
    [super viewWillAppear:YES];
}
- (BOOL)textFieldShouldReturn:(UITextField *)textField
{
    if (textField == CustomerField) {
		[textField resignFirstResponder];
        [FirstnameField becomeFirstResponder];
    }
    else if (textField == FirstnameField) {
		[textField resignFirstResponder];
        [LastnameField becomeFirstResponder];
    }
    else if (textField == LastnameField) {
		[textField resignFirstResponder];
        [EmailField becomeFirstResponder];
    }
    else if (textField == EmailField) {
		[textField resignFirstResponder];
        
    }
    return YES;

}
-(void)showTime
{
    
    NSDate *aDate = [NSDate date];
    NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
    [formatter setDateStyle:NSDateFormatterShortStyle];
    [formatter setTimeStyle:NSDateFormatterNoStyle];
    [formatter setDateFormat:@"HH:mm:ss"];
    NSString *datestr;
    datestr=[formatter stringFromDate:aDate];
    Timelbl.text=datestr;
    // Timelbl.text=[NSString stringWithFormat:@"%@:%@",@"Time",datestr];
    //Timelbl.text=[[NSDate date] description];
    
    
}
-(void)segmentchanged4:(UISegmentedControl *)sender
{
    //// //NSLog(@"active results %@ ",[[pagination sharedInstance]activeresultset]);
    [customerPaginationObject  activateResults:[customerPaginationObject paginationsegment].selectedSegmentIndex];
    [self GetCustomerDataMethod];
    [EditCustomerTable reloadData];
}
-(void)infoButton1Clicked:(UIButton *)sender
{
    
    
    NSInteger selectedbtn=sender.tag;
    
    NSString *num=CustomerField.text;
    if ([num length]<=0){
        UIAlertView *alert=[[UIAlertView alloc] initWithTitle:@"message" message:@"Please Enter customer ID" delegate:self cancelButtonTitle:@"ok" otherButtonTitles:Nil, nil];
        [alert show];
    }else{
    
    if (selectedbtn==100){
        if (!GeneralInfoPopUp)
        GeneralInfoPopUp=[[UIView alloc]init];
        if (isLandScope) {
            GeneralInfoPopUp.frame=CGRectMake(0, 0, 1024, 768);
        }else{
            
            GeneralInfoPopUp.frame=CGRectMake(0, 0, 768, 1024);
        }
        [GeneralInfoPopUp setBackgroundColor:[UIColor colorWithRed:10.0f/255.0f green:10.0f/255.0f blue:10.0f/255.0f alpha:0.7f/1.0f]];
        [self.view addSubview:GeneralInfoPopUp];
         if (!GeneralInfoView)
        GeneralInfoView=[[UIScrollView alloc] init];
        if (isLandScope){
             GeneralInfoView.frame=CGRectMake(50, 100, GeneralInfoPopUp.frame.size.width-100, GeneralInfoPopUp.frame.size.height-250);
             GeneralInfoView.contentSize=CGSizeMake(GeneralInfoPopUp.frame.size.width-100, GeneralInfoPopUp.frame.size.height);
        }else{
             GeneralInfoView.frame=CGRectMake(50, 150, GeneralInfoPopUp.frame.size.width-100, GeneralInfoPopUp.frame.size.height-500);
             GeneralInfoView.contentSize=CGSizeMake(GeneralInfoPopUp.frame.size.width-100, GeneralInfoPopUp.frame.size.height);
        }
        [GeneralInfoView setBackgroundColor:[UIColor colorWithRed:0.0f green:74.0f/255.0f blue:132.0f/255.0f alpha:1.0f]];
        
        [GeneralInfoView.layer setBorderWidth:2.0];
        [GeneralInfoView.layer setBorderColor:[[UIColor whiteColor] CGColor]];
        [GeneralInfoPopUp addSubview:GeneralInfoView];
        
        CGFloat fieldwidth=(GeneralInfoView.frame.size.width)/4;
        
         CGFloat o=(fieldwidth/2);
         if (!GeneralInfoTextlbl)
        GeneralInfoTextlbl=[[UILabel alloc] init];
        GeneralInfoTextlbl.frame=CGRectMake(fieldwidth+60, 10,fieldwidth+100, 40);
       [GeneralInfoTextlbl setFont:[UIFont systemFontOfSize:25.0f]];
        [GeneralInfoTextlbl setBackgroundColor:[UIColor clearColor]];
        [GeneralInfoTextlbl setTextColor:[UIColor whiteColor]];
       
        [GeneralInfoTextlbl setText:@"General Info Details"];
        [GeneralInfoTextlbl setTextAlignment:NSTextAlignmentLeft];
        [GeneralInfoView addSubview:GeneralInfoTextlbl];
        NSArray *labelArray;
        if (!labelArray)
        labelArray=[[NSArray alloc] initWithObjects:@"Company Name",@"Street Address ",@"Street Address2",@"City",@"Country",nil];
        int d=60;
        
        for (int i=0; i<5; i++)
        {
            
            GeneralInfolbl=[[UILabel alloc] init];
            GeneralInfolbl.frame=CGRectMake(o-60, d,fieldwidth+10, 40);
            GeneralInfolbl.tag=i+100;
            [GeneralInfolbl setFont:[UIFont systemFontOfSize:20.0f]];
            [GeneralInfolbl setBackgroundColor:[UIColor clearColor]];
            [GeneralInfolbl setTextColor:[UIColor whiteColor]];
            [GeneralInfolbl setText:[labelArray objectAtIndex:i]];
            [GeneralInfolbl setTextAlignment:NSTextAlignmentLeft];
            [GeneralInfoView addSubview:GeneralInfolbl];
            //// //NSLog(@"%f",generalinfolbl.frame.origin.y);
            GeneralInfoField=[[UITextField alloc] init];
            //[nameTextfield setBorderStyle:UITextBorderStyleRoundedRect];
            GeneralInfoField.frame=CGRectMake(GeneralInfolbl.frame.size.width+5, d,fieldwidth-10, 40);
            GeneralInfoField.delegate=self;
            GeneralInfoField.tag=i+100;
            
            UIView *paddingview=[[UIView alloc] initWithFrame:CGRectMake(5, 0, 5, 20)];
            // // //NSLog(@"%f",GeneralinfoField.frame.origin.y);
            GeneralInfoField.leftView = paddingview;
            GeneralInfoField.contentVerticalAlignment=UIControlContentVerticalAlignmentCenter;
            GeneralInfoField.leftViewMode = UITextFieldViewModeAlways;
            [GeneralInfoField setBackground:[UIImage imageNamed:@"addinputtextfield.png"]];
            
            if (GeneralInfoField.tag==100)
            {
                GeneralInfoField.text=GCompanyName;
            }
            if (GeneralInfoField.tag==101)
            {
                GeneralInfoField.text=GStreetAddress;
            }
            if (GeneralInfoField.tag==102)
            {
                GeneralInfoField.text=GStreetAddress2;
            }
            if (GeneralInfoField.tag==103)
            {
                GeneralInfoField.text=Gcity;
            }
            if (GeneralInfoField.tag==104)
            {
                GeneralInfoField.text=GCountry;
            }
            [GeneralInfoField addTarget:self action:@selector(GeneralinfoFieldClicked:) forControlEvents:UIControlEventEditingDidEnd];
            [GeneralInfoField setAutocorrectionType:UITextAutocorrectionTypeNo];
            
            //[dataField addTarget:self action:@selector(adddata:) forControlEvents:UIControlEventTouchUpInside];
            
            [GeneralInfoView addSubview:GeneralInfoField];
            
            d=d+60;
            paddingview=nil;
            
        }
        NSArray *labelArray2;
        if (!labelArray2)
        labelArray2=[[NSArray alloc] initWithObjects:@"Primary Phone#",@"Alertnate Phone",@"Birthday",@"State",@"Zipcode",nil];
        int b=60;
        
        for (int i=0; i<5; i++)
        {
            
            GeneralInfolbl2=[[UILabel alloc] init];
            GeneralInfolbl2.frame=CGRectMake(GeneralInfolbl.frame.size.width+5+GeneralInfoField.frame.size.width+5, b,fieldwidth+10, 40);
            
            GeneralInfolbl2.tag=i+100;
            [GeneralInfolbl2 setFont:[UIFont systemFontOfSize:20.0f]];
            [GeneralInfolbl2 setBackgroundColor:[UIColor clearColor]];
            [GeneralInfolbl2 setTextColor:[UIColor whiteColor]];
           
            [GeneralInfolbl2 setText:[labelArray2 objectAtIndex:i]];
            [GeneralInfolbl2 setTextAlignment:NSTextAlignmentLeft];
            [GeneralInfoView addSubview:GeneralInfolbl2];
            //// //NSLog(@"%f",generalinfolbl.frame.origin.y);
            GeneralInfoField2=[[UITextField alloc] init];
            //[nameTextfield setBorderStyle:UITextBorderStyleRoundedRect];
            GeneralInfoField2.frame=CGRectMake(GeneralInfolbl.frame.size.width+GeneralInfoField.frame.size.width+GeneralInfolbl2.frame.size.width-5, b,fieldwidth-10, 40);
            GeneralInfoField2.delegate=self;
            GeneralInfoField2.tag=i+100;
            
            UIView *paddingview=[[UIView alloc] initWithFrame:CGRectMake(5, 0, 5, 20)];
            // // //NSLog(@"%f",GeneralinfoField.frame.origin.y);
            GeneralInfoField2.leftView = paddingview;
            GeneralInfoField2.contentVerticalAlignment=UIControlContentVerticalAlignmentCenter;
            GeneralInfoField2.leftViewMode = UITextFieldViewModeAlways;
            
            [GeneralInfoField2 setBackground:[UIImage imageNamed:@"addinputtextfield.png"]];
            if (GeneralInfoField2.tag==100)
            {
                GeneralInfoField2.text=Gphone;
            }
            if (GeneralInfoField2.tag==101)
            {
                GeneralInfoField2.text=GAlternatePhone;
            }
            if (GeneralInfoField2.tag==102)
            {
                GeneralInfoField2.text=GBirthDay;
            }
            if (GeneralInfoField2.tag==103)
            {
                GeneralInfoField2.text=Gstate;
            }
            if (GeneralInfoField2.tag==104)
            {
                GeneralInfoField2.text=GpostalCode;
            }
            [GeneralInfoField2 addTarget:self action:@selector(GeneralinfoFieldClicked2:) forControlEvents:UIControlEventEditingDidEnd];
            [GeneralInfoField2 setAutocorrectionType:UITextAutocorrectionTypeNo];
            
            //[dataField addTarget:self action:@selector(adddata:) forControlEvents:UIControlEventTouchUpInside];
            
            [GeneralInfoView addSubview:GeneralInfoField2];
            
            b=b+60;
            paddingview=nil;
            
        }

        @autoreleasepool {
            SaveGeneralInfoBtn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
            
            SaveGeneralInfoBtn.frame=CGRectMake(fieldwidth+80, 400, 80, 30);
            [SaveGeneralInfoBtn addTarget:self action:@selector(SaveGeneralInfoData) forControlEvents:UIControlEventTouchUpInside];
            
            //[SaveTaxButton setTitle:@"Save" forState:UIControlStateNormal];
            [SaveGeneralInfoBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
            [SaveGeneralInfoBtn setBackgroundImage:[UIImage imageNamed:@"savegreenbutton.png"] forState:UIControlStateNormal];
            [GeneralInfoView addSubview:SaveGeneralInfoBtn];
            
            CancelGeneralInfoBtn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
            
            CancelGeneralInfoBtn.frame=CGRectMake(fieldwidth+240, 400, 80, 30);
            [CancelGeneralInfoBtn addTarget:self action:@selector(CancelGeneralInfo) forControlEvents:UIControlEventTouchUpInside];
            [CancelGeneralInfoBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
            [CancelGeneralInfoBtn setBackgroundImage:[UIImage imageNamed:@"cancelgreenbutton.png"] forState:UIControlStateNormal];
            // [CancelTaxButton setTitle:@"Cancel" forState:UIControlStateNormal];
            [GeneralInfoView addSubview:CancelGeneralInfoBtn];
        }
      
        
        
    }else if (selectedbtn==101){
        if (!ExtendedInfopopUp)
        ExtendedInfopopUp=[[UIView alloc]init];
        if (isLandScope) {
            ExtendedInfopopUp.frame=CGRectMake(0, 0, 1024, 768);
        }else{
            
            ExtendedInfopopUp.frame=CGRectMake(0, 0, 768, 1024);
        }
        [ExtendedInfopopUp setBackgroundColor:[UIColor colorWithRed:10.0f/255.0f green:10.0f/255.0f blue:10.0f/255.0f alpha:0.7f/1.0f]];
        [self.view addSubview:ExtendedInfopopUp];
         if (!ExtendedInfoView)
        ExtendedInfoView=[[UIScrollView alloc] init];
        if (isLandScope) {
             ExtendedInfoView.frame=CGRectMake(50, 100, ExtendedInfopopUp.frame.size.width-100, ExtendedInfopopUp.frame.size.height-250);
            ExtendedInfoView.contentSize=CGSizeMake(ExtendedInfopopUp.frame.size.width-100, ExtendedInfopopUp.frame.size.height);
        }else{
             ExtendedInfoView.frame=CGRectMake(50, 150, ExtendedInfopopUp.frame.size.width-100, ExtendedInfopopUp.frame.size.height-500);
            ExtendedInfoView.contentSize=CGSizeMake(ExtendedInfopopUp.frame.size.width-100, ExtendedInfopopUp.frame.size.height);
        }
        [ExtendedInfoView setBackgroundColor:[UIColor colorWithRed:0.0f green:74.0f/255.0f blue:132.0f/255.0f alpha:1.0f]];
        
        [ExtendedInfoView.layer setBorderWidth:2.0];
        [ExtendedInfoView.layer setBorderColor:[[UIColor whiteColor] CGColor]];
        [ExtendedInfopopUp addSubview:ExtendedInfoView];
        
        CGFloat Efieldwidth=(ExtendedInfoView.frame.size.width)/4;
        
        CGFloat E=(Efieldwidth/2);
         if (!ExdInfotextlbl)
        ExdInfotextlbl=[[UILabel alloc] init];
        ExdInfotextlbl.frame=CGRectMake(Efieldwidth+60, 10,Efieldwidth+100, 40);
        [ExdInfotextlbl setFont:[UIFont systemFontOfSize:25.0f]];
        [ExdInfotextlbl setBackgroundColor:[UIColor clearColor]];
        [ExdInfotextlbl setTextColor:[UIColor whiteColor]];
        [ExdInfotextlbl setText:@"Extended Info Details"];
        [ExdInfotextlbl setTextAlignment:NSTextAlignmentLeft];
        [ExtendedInfoView addSubview:ExdInfotextlbl];
          if (!CreditcardInfolbl)
        CreditcardInfolbl=[[UILabel alloc] init];
        CreditcardInfolbl.frame=CGRectMake(Efieldwidth-40, 50,Efieldwidth+50, 40);
        [CreditcardInfolbl setFont:[UIFont systemFontOfSize:20.0f]];
        [CreditcardInfolbl setBackgroundColor:[UIColor clearColor]];
        [CreditcardInfolbl setTextColor:[UIColor whiteColor]];
        [CreditcardInfolbl setText:@"CreditCard Info"];
        [CreditcardInfolbl setTextAlignment:NSTextAlignmentLeft];
        [ExtendedInfoView addSubview:CreditcardInfolbl];
          if (!CreditCardtypesArray)
        CreditCardtypesArray=[[NSArray alloc]initWithObjects:@"Visa",@"Master card",@"American Express",@"Discover Card",@"JCB",@"DINERS CLUB INTERNATIONAL", nil];
         if (!PersonalInfolbl)
        PersonalInfolbl=[[UILabel alloc] init];
        PersonalInfolbl.frame=CGRectMake(Efieldwidth+CreditcardInfolbl.frame.size.width+40, 50,Efieldwidth+100, 40);
        [PersonalInfolbl setFont:[UIFont systemFontOfSize:20.0f]];
        [PersonalInfolbl setBackgroundColor:[UIColor clearColor]];
        [PersonalInfolbl setTextColor:[UIColor whiteColor]];
        [PersonalInfolbl setText:@"Personal Info"];
        [PersonalInfolbl setTextAlignment:NSTextAlignmentLeft];
        [ExtendedInfoView addSubview:PersonalInfolbl];
        NSArray *labelArray;
        if (!labelArray)
        labelArray=[[NSArray alloc] initWithObjects:@"CreditCardNumber",@"Expiration",nil];
        
        int d=100;
        
        for (int i=0; i<2; i++)
        {
            
            ExtendedInfolbl=[[UILabel alloc] init];
            ExtendedInfolbl.frame=CGRectMake(E-70, d,Efieldwidth+10, 40);
            ExtendedInfolbl.tag=i+100;
            [ExtendedInfolbl setFont:[UIFont systemFontOfSize:20.0f]];
            [ExtendedInfolbl setBackgroundColor:[UIColor clearColor]];
            [ExtendedInfolbl setTextColor:[UIColor whiteColor]];
             [ExtendedInfolbl setText:[labelArray objectAtIndex:i]];
            ExtendedInfolbl.lineBreakMode = NSLineBreakByWordWrapping;
            ExtendedInfolbl.numberOfLines = 2;
            [ExtendedInfolbl setTextAlignment:NSTextAlignmentLeft];
            [ExtendedInfoView addSubview:ExtendedInfolbl];
            //// //NSLog(@"%f",generalinfolbl.frame.origin.y);
            ExtendedField=[[UITextField alloc] init];
            //[nameTextfield setBorderStyle:UITextBorderStyleRoundedRect];
            ExtendedField.frame=CGRectMake(ExtendedInfolbl.frame.size.width+5, d,Efieldwidth-10, 40);
            ExtendedField.delegate=self;
            ExtendedField.tag=i+100;
            
            UIView *paddingview=[[UIView alloc] initWithFrame:CGRectMake(5, 0, 5, 20)];
            // // //NSLog(@"%f",GeneralinfoField.frame.origin.y);
            ExtendedField.leftView = paddingview;
            ExtendedField.contentVerticalAlignment=UIControlContentVerticalAlignmentCenter;
            ExtendedField.leftViewMode = UITextFieldViewModeAlways;
            [ExtendedField setBackground:[UIImage imageNamed:@"addinputtextfield.png"]];
            if (ExtendedField.tag==100)
            {
                ExtendedField.text=CardNo;
                
            }
            if (ExtendedField.tag==101)
            {
                ExtendedField.text=Expiration;
                
            }
           
            [ExtendedField addTarget:self action:@selector(ExtendedinfoFieldClicked:) forControlEvents:UIControlEventEditingDidEnd];
            [ExtendedField setAutocorrectionType:UITextAutocorrectionTypeNo];
           
            
            //[dataField addTarget:self action:@selector(adddata:) forControlEvents:UIControlEventTouchUpInside];
            
            [ExtendedInfoView addSubview:ExtendedField];
            
            d=d+70;
            paddingview=nil;
            
        }
        // //NSLog(@"%d",d);
        if (!CreditCardtypelbl)
        CreditCardtypelbl=[[UILabel alloc] init];
        CreditCardtypelbl.frame=CGRectMake(E-70, 240,Efieldwidth+10, 40);
        [CreditCardtypelbl setFont:[UIFont systemFontOfSize:20.0f]];
        [CreditCardtypelbl setBackgroundColor:[UIColor clearColor]];
        [CreditCardtypelbl setTextColor:[UIColor whiteColor]];
        [CreditCardtypelbl setText:@"Credit Card Type"];
        CreditCardtypelbl.lineBreakMode = NSLineBreakByWordWrapping;
        CreditCardtypelbl.numberOfLines = 2;
        [CreditCardtypelbl setTextAlignment:NSTextAlignmentLeft];
        [ExtendedInfoView addSubview:CreditCardtypelbl];
        if (!CreditCardTypeBtn)
        CreditCardTypeBtn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
        CreditCardTypeBtn.frame=CGRectMake(ExtendedInfolbl.frame.size.width+5, 240,Efieldwidth-10, 40);
        [CreditCardTypeBtn addTarget:self action:@selector(CreditCardTypeclicked:) forControlEvents:UIControlEventTouchUpInside];
        [CreditCardTypeBtn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
        [CreditCardTypeBtn setBackgroundImage:[UIImage imageNamed:@"drop-down-icon.png"] forState:UIControlStateNormal];
         [CreditCardTypeBtn setTitle:cardType forState:UIControlStateNormal];
        // [CancelTaxButton setTitle:@"Cancel" forState:UIControlStateNormal];
        [ExtendedInfoView addSubview:CreditCardTypeBtn];
         if (!CreadidCardListTable)
        CreadidCardListTable = [[UITableView alloc] initWithFrame:CGRectMake(ExtendedInfolbl.frame.size.width+5, 280,Efieldwidth-10, 100) style:UITableViewStylePlain];
        CreadidCardListTable.backgroundColor=[UIColor whiteColor];
        CreadidCardListTable.delegate = self;
        CreadidCardListTable.dataSource = self;
        CreadidCardListTable.scrollEnabled = YES;
        CreadidCardListTable.hidden=YES;
        [CreadidCardListTable.layer setBorderWidth: 1.0];
        [CreadidCardListTable.layer setBorderColor:[[UIColor grayColor] CGColor]];
        [ExtendedInfoView addSubview:CreadidCardListTable];
        NSArray *labelArray2;
        if (!labelArray2)
         labelArray2 =[[NSArray alloc] initWithObjects:@"DriversLicenseId",@"Exp Date",@"Mobile Phone",@"Fax",nil];
        int b=100;
        
        for (int i=0; i<4; i++)
        {
            
            Extendedblbl2=[[UILabel alloc] init];
            Extendedblbl2.frame=CGRectMake(ExtendedInfolbl.frame.size.width+5+ExtendedField.frame.size.width+5, b,Efieldwidth+10, 40);
            Extendedblbl2.tag=i+100;
            [Extendedblbl2 setFont:[UIFont systemFontOfSize:20.0f]];
            [Extendedblbl2 setBackgroundColor:[UIColor clearColor]];
            [Extendedblbl2 setTextColor:[UIColor whiteColor]];
           [Extendedblbl2 setText:[labelArray2 objectAtIndex:i]];
            Extendedblbl2.lineBreakMode = NSLineBreakByWordWrapping;
            Extendedblbl2.numberOfLines = 2;
            [Extendedblbl2 setTextAlignment:NSTextAlignmentLeft];
            [ExtendedInfoView addSubview:Extendedblbl2];
            //// //NSLog(@"%f",generalinfolbl.frame.origin.y);
            ExtendedField2=[[UITextField alloc] init];
            //[nameTextfield setBorderStyle:UITextBorderStyleRoundedRect];
            ExtendedField2.frame=CGRectMake(ExtendedInfolbl.frame.size.width+ExtendedField.frame.size.width+Extendedblbl2.frame.size.width-15, b,Efieldwidth-10, 40);
            ExtendedField2.delegate=self;
            ExtendedField2.tag=i+100;
            
            UIView *paddingview=[[UIView alloc] initWithFrame:CGRectMake(5, 0, 5, 20)];
            // // //NSLog(@"%f",GeneralinfoField.frame.origin.y);
            ExtendedField2.leftView = paddingview;
            ExtendedField2.contentVerticalAlignment=UIControlContentVerticalAlignmentCenter;
            ExtendedField2.leftViewMode = UITextFieldViewModeAlways;
            [ExtendedField2 setBackground:[UIImage imageNamed:@"addinputtextfield.png"]];
            if (ExtendedField2.tag==100)
            {
                ExtendedField2.text=LicenseId;
                
            }
            if (ExtendedField2.tag==101)
            {
                ExtendedField2.text=ExpDate;
                
            }
            if (ExtendedField2.tag==102)
            {
                ExtendedField2.text=MPhone;
                
            }
            if (ExtendedField2.tag==103)
            {
                ExtendedField2.text=Fax;
                
            }
            [ExtendedField2 addTarget:self action:@selector(ExtendedinfoFieldClicked2:) forControlEvents:UIControlEventEditingDidEnd];
            [ExtendedField2 setAutocorrectionType:UITextAutocorrectionTypeNo];
            
            //[dataField addTarget:self action:@selector(adddata:) forControlEvents:UIControlEventTouchUpInside];
            
            [ExtendedInfoView addSubview:ExtendedField2];
            
            b=b+70;
            paddingview=nil;
            
        }
        
        @autoreleasepool {
            SaveExtendedInfoBtn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
            
            SaveExtendedInfoBtn.frame=CGRectMake(Efieldwidth+80, 420, 80, 30);
            [SaveExtendedInfoBtn addTarget:self action:@selector(SaveExtendedData) forControlEvents:UIControlEventTouchUpInside];
            
            //[SaveTaxButton setTitle:@"Save" forState:UIControlStateNormal];
            [SaveExtendedInfoBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
            [SaveExtendedInfoBtn setBackgroundImage:[UIImage imageNamed:@"savegreenbutton.png"] forState:UIControlStateNormal];
            [ExtendedInfoView addSubview:SaveExtendedInfoBtn];
            
            CancelExtendedInfoBtn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
            
            CancelExtendedInfoBtn.frame=CGRectMake(Efieldwidth+230, 420, 80, 30);
            [CancelExtendedInfoBtn addTarget:self action:@selector(CancelExtendedInfo) forControlEvents:UIControlEventTouchUpInside];
            [CancelExtendedInfoBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
            [CancelExtendedInfoBtn setBackgroundImage:[UIImage imageNamed:@"cancelgreenbutton.png"] forState:UIControlStateNormal];
            // [CancelTaxButton setTitle:@"Cancel" forState:UIControlStateNormal];
            [ExtendedInfoView addSubview:CancelExtendedInfoBtn];
        }
     
        
        
    }else if (selectedbtn==102){
        if (!ShippingInfoPopUp)
        ShippingInfoPopUp=[[UIView alloc]init];
        if (isLandScope) {
            ShippingInfoPopUp.frame=CGRectMake(0, 0, 1024, 768);
        }else{
            ShippingInfoPopUp.frame=CGRectMake(0, 0, 768, 1024);
        }
        [ShippingInfoPopUp setBackgroundColor:[UIColor colorWithRed:10.0f/255.0f green:10.0f/255.0f blue:10.0f/255.0f alpha:0.7f/1.0f]];
        [self.view addSubview:ShippingInfoPopUp];
        if (!ShippingInfoView)
        ShippingInfoView=[[UIScrollView alloc] init];
        if (isLandScope) {
             ShippingInfoView.frame=CGRectMake(50, 100, ShippingInfoPopUp.frame.size.width-100, ShippingInfoPopUp.frame.size.height-250);
            ShippingInfoView.contentSize=CGSizeMake(ShippingInfoPopUp.frame.size.width-100, ShippingInfoPopUp.frame.size.height);
        }else{
             ShippingInfoView.frame=CGRectMake(50, 200, ShippingInfoPopUp.frame.size.width-100, ShippingInfoPopUp.frame.size.height-500);
            ShippingInfoView.contentSize=CGSizeMake(ShippingInfoPopUp.frame.size.width-100, ShippingInfoPopUp.frame.size.height);
        }
        [ShippingInfoView setBackgroundColor:[UIColor colorWithRed:0.0f green:74.0f/255.0f blue:132.0f/255.0f alpha:1.0f]];
        [ShippingInfoView.layer setBorderWidth:2.0];
        [ShippingInfoView.layer setBorderColor:[[UIColor whiteColor] CGColor]];
        [ShippingInfoPopUp addSubview:ShippingInfoView];
        
        CGFloat fieldwidth=(ShippingInfoView.frame.size.width)/4;
        
        CGFloat o=(fieldwidth/2);
         if (!ShippingInfoTextlbl)
        ShippingInfoTextlbl=[[UILabel alloc] init];
        ShippingInfoTextlbl.frame=CGRectMake(fieldwidth+60, 10,fieldwidth+100, 40);
        [ShippingInfoTextlbl setFont:[UIFont systemFontOfSize:25.0f]];
        [ShippingInfoTextlbl setBackgroundColor:[UIColor clearColor]];
        [ShippingInfoTextlbl setTextColor:[UIColor whiteColor]];
        [ShippingInfoTextlbl setText:@"Shipping Info Details"];
        [ShippingInfoTextlbl setTextAlignment:NSTextAlignmentLeft];
        [ShippingInfoView addSubview:ShippingInfoTextlbl];
        NSArray *labelArray;
         if (!labelArray)
        labelArray=[[NSArray alloc] initWithObjects:@"First Name",@"Company Name ",@"Street Address",@"City",@"Country",nil];
        int d=60;
        
        for (int i=0; i<5; i++)
        {
            
             ShippingInfolbl=[[UILabel alloc] init];
            ShippingInfolbl.frame=CGRectMake(o-60, d,fieldwidth+10, 40);
            ShippingInfolbl.tag=i+100;
            [ShippingInfolbl setFont:[UIFont systemFontOfSize:20.0f]];
            [ShippingInfolbl setBackgroundColor:[UIColor clearColor]];
            [ShippingInfolbl setTextColor:[UIColor whiteColor]];
            [ShippingInfolbl setText:[labelArray objectAtIndex:i]];
            [ShippingInfolbl setTextAlignment:NSTextAlignmentLeft];
            [ShippingInfoView addSubview:ShippingInfolbl];
            //// //NSLog(@"%f",generalinfolbl.frame.origin.y);
            ShippingInfoField=[[UITextField alloc] init];
            //[nameTextfield setBorderStyle:UITextBorderStyleRoundedRect];
            ShippingInfoField.frame=CGRectMake(ShippingInfolbl.frame.size.width+5, d,fieldwidth-10, 40);
            ShippingInfoField.delegate=self;
            ShippingInfoField.tag=i+100;
            
            UIView *paddingview=[[UIView alloc] initWithFrame:CGRectMake(5, 0, 5, 20)];
            // // //NSLog(@"%f",GeneralinfoField.frame.origin.y);
            ShippingInfoField.leftView = paddingview;
            ShippingInfoField.contentVerticalAlignment=UIControlContentVerticalAlignmentCenter;
            ShippingInfoField.leftViewMode = UITextFieldViewModeAlways;
            [ShippingInfoField setBackground:[UIImage imageNamed:@"addinputtextfield.png"]];
            if (ShippingInfoField.tag==100)
            {
                ShippingInfoField.text=ShCompanyName;
            }
            if (ShippingInfoField.tag==101)
            {
                ShippingInfoField.text=ShStreetAddress;
            }
            if (ShippingInfoField.tag==102)
            {
                ShippingInfoField.text=ShStreetAddress2;
            }
            if (ShippingInfoField.tag==103)
            {
                ShippingInfoField.text=Shcity;
            }
            if (ShippingInfoField.tag==104)
            {
                ShippingInfoField.text=ShCountry;
            }
            [ShippingInfoField addTarget:self action:@selector(ShippinginfoFieldClicked:) forControlEvents:UIControlEventEditingDidEnd];
            [ShippingInfoField setAutocorrectionType:UITextAutocorrectionTypeNo];
            
            //[dataField addTarget:self action:@selector(adddata:) forControlEvents:UIControlEventTouchUpInside];
            
            [ShippingInfoView addSubview:ShippingInfoField];
            
            d=d+60;
            paddingview=nil;
            
        }
        NSArray *labelArray2;
        if (!labelArray2)
        labelArray2=[[NSArray alloc] initWithObjects:@"Last Name",@"Phone Number",@"ExtendedAddress",@"State",@"Zipcode",nil];
        int b=60;
        
        for (int i=0; i<5; i++)
        {
            
           ShippingInfolbl2=[[UILabel alloc] init];
            ShippingInfolbl2.frame=CGRectMake(ShippingInfolbl.frame.size.width+5+ShippingInfoField.frame.size.width+5, b,fieldwidth+10, 40);
            
            ShippingInfolbl2.tag=i+100;
            [ShippingInfolbl2 setFont:[UIFont systemFontOfSize:20.0f]];
            [ShippingInfolbl2 setBackgroundColor:[UIColor clearColor]];
            [ShippingInfolbl2 setTextColor:[UIColor whiteColor]];
           
            [ShippingInfolbl2 setText:[labelArray2 objectAtIndex:i]];
            [ShippingInfolbl2 setTextAlignment:NSTextAlignmentLeft];
            [ShippingInfoView addSubview:ShippingInfolbl2];
            //// //NSLog(@"%f",generalinfolbl.frame.origin.y);
            ShippingInfoField2=[[UITextField alloc] init];
            //[nameTextfield setBorderStyle:UITextBorderStyleRoundedRect];
            ShippingInfoField2.frame=CGRectMake(ShippingInfolbl.frame.size.width+ShippingInfoField.frame.size.width+ShippingInfolbl2.frame.size.width-5, b,fieldwidth-10, 40);
            ShippingInfoField2.delegate=self;
            ShippingInfoField2.tag=i+100;
            
            UIView *paddingview=[[UIView alloc] initWithFrame:CGRectMake(5, 0, 5, 20)];
            // // //NSLog(@"%f",GeneralinfoField.frame.origin.y);
            ShippingInfoField2.leftView = paddingview;
            ShippingInfoField2.contentVerticalAlignment=UIControlContentVerticalAlignmentCenter;
            ShippingInfoField2.leftViewMode = UITextFieldViewModeAlways;
            [ShippingInfoField2 setBackground:[UIImage imageNamed:@"addinputtextfield.png"]];
            if (ShippingInfoField2.tag==100)
            {
                ShippingInfoField2.text=Shphone;
            }
            if (ShippingInfoField2.tag==101)
            {
                ShippingInfoField2.text=ShAlternatePhone;
            }
            if (ShippingInfoField2.tag==102)
            {
                ShippingInfoField2.text=ShBirthDay;
            }
            if (ShippingInfoField2.tag==103)
            {
                ShippingInfoField2.text=Shstate;
            }
            if (ShippingInfoField2.tag==104)
            {
                ShippingInfoField2.text=ShpostalCode;
            }
            [ShippingInfoField2 addTarget:self action:@selector(ShippinginfoFieldClicked2:) forControlEvents:UIControlEventEditingDidEnd];
            [ShippingInfoField2 setAutocorrectionType:UITextAutocorrectionTypeNo];
            
            //[dataField addTarget:self action:@selector(adddata:) forControlEvents:UIControlEventTouchUpInside];
            
            [ShippingInfoView addSubview:ShippingInfoField2];
            
            b=b+60;
            paddingview=nil;
            
        }
        
        @autoreleasepool {
            SaveShippingInfoBtn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
            
            SaveShippingInfoBtn.frame=CGRectMake(fieldwidth+80, 400, 80, 30);
            [SaveShippingInfoBtn addTarget:self action:@selector(SaveShippingData) forControlEvents:UIControlEventTouchUpInside];
            
            //[SaveTaxButton setTitle:@"Save" forState:UIControlStateNormal];
            [SaveShippingInfoBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
            [SaveShippingInfoBtn setBackgroundImage:[UIImage imageNamed:@"savegreenbutton.png"] forState:UIControlStateNormal];
            [ShippingInfoView addSubview:SaveShippingInfoBtn];
            
            CancelShippingInfoBtn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
            
            CancelShippingInfoBtn.frame=CGRectMake(fieldwidth+220, 400, 80, 30);
            [CancelShippingInfoBtn addTarget:self action:@selector(CancelShippingInfo) forControlEvents:UIControlEventTouchUpInside];
            [CancelShippingInfoBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
            [CancelShippingInfoBtn setBackgroundImage:[UIImage imageNamed:@"cancelgreenbutton.png"] forState:UIControlStateNormal];
            // [CancelTaxButton setTitle:@"Cancel" forState:UIControlStateNormal];
            [ShippingInfoView addSubview:CancelShippingInfoBtn];

        }
    }else  if (selectedbtn==104){
        if (!NotesBackView)
        NotesBackView=[[UIView alloc]init];
        if (isLandScope) {
            NotesBackView.frame=CGRectMake(0, 0, 1024, 768);
        }else{
            
            NotesBackView.frame=CGRectMake(0, 0, 768, 1024);
        }
        [NotesBackView setBackgroundColor:[UIColor colorWithRed:10.0f/255.0f green:10.0f/255.0f blue:10.0f/255.0f alpha:0.7f/1.0f]];
        [self.view addSubview:NotesBackView];
        if (!NotesView)
        NotesView=[[UIView alloc] init];
        if (isLandScope){
            
            NotesView.frame=CGRectMake(50, 50, NotesBackView.frame.size.width-100, NotesBackView.frame.size.height-150);
        }else{
            NotesView.frame=CGRectMake(50, 150, NotesBackView.frame.size.width-100, NotesBackView.frame.size.height-400);
        }
        [NotesView setBackgroundColor:[UIColor colorWithRed:0.0f green:74.0f/255.0f blue:132.0f/255.0f alpha:1.0f]];
        [NotesView.layer setBorderWidth:2.0];
        [NotesView.layer setBorderColor:[[UIColor whiteColor] CGColor]];
        [NotesBackView addSubview:NotesView];
        
        CGFloat widthfield3=(NotesView.frame.size.width)/4;
        if (!Notestextlbl)
        Notestextlbl=[[UILabel alloc] init];
        Notestextlbl.frame=CGRectMake(widthfield3+100,10,widthfield3,40);
        [Notestextlbl setFont:[UIFont systemFontOfSize:25.0f]];
        [Notestextlbl setBackgroundColor:[UIColor clearColor]];
        [Notestextlbl setTextColor:[UIColor whiteColor]];
        [Notestextlbl setText:@"Notes Details"];
        [Notestextlbl setTextAlignment:NSTextAlignmentLeft];
        [NotesView addSubview:Notestextlbl];
        if (!EnterNoteslbl)
        EnterNoteslbl=[[UILabel alloc] init];
        EnterNoteslbl.frame=CGRectMake(widthfield3-60,60,widthfield3,40);
        [EnterNoteslbl setFont:[UIFont systemFontOfSize:20.0f]];
        [EnterNoteslbl setBackgroundColor:[UIColor clearColor]];
        [EnterNoteslbl setTextColor:[UIColor whiteColor]];
        [EnterNoteslbl setText:@"Enter Notes"];
        [EnterNoteslbl setTextAlignment:NSTextAlignmentLeft];
        [NotesView addSubview:EnterNoteslbl];
         if (!NotesTextView)
        NotesTextView=[[UITextView alloc] init];
        NotesTextView.frame=CGRectMake(10, 115,NotesView.frame.size.width-20,400);
        NotesTextView.delegate=self;
        NotesTextView.text=CustomerNotes;
        NotesTextView.font=[UIFont systemFontOfSize:14.0f];
        [NotesTextView setAutocorrectionType:UITextAutocorrectionTypeNo];
        NotesTextView.layer.cornerRadius=8;
        [NotesView addSubview:NotesTextView];
        @autoreleasepool {
            SaveNotesBtn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
            SaveNotesBtn.frame=CGRectMake(widthfield3+80,540,80,30);
            [SaveNotesBtn addTarget:self action:@selector(SaveProductNotes) forControlEvents:UIControlEventTouchUpInside];
            //[SaveTaxButton setTitle:@"Save" forState:UIControlStateNormal];
            [SaveNotesBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
            [SaveNotesBtn setBackgroundImage:[UIImage imageNamed:@"savegreenbutton.png"] forState:UIControlStateNormal];
            [NotesView addSubview:SaveNotesBtn];
            
            CancelNotesBtn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
            CancelNotesBtn.frame=CGRectMake(widthfield3+230,540,80,30);
            [CancelNotesBtn addTarget:self action:@selector(NotesCancelclicked) forControlEvents:UIControlEventTouchUpInside];
            [CancelNotesBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
            [CancelNotesBtn setBackgroundImage:[UIImage imageNamed:@"cancelgreenbutton.png"] forState:UIControlStateNormal];
            // [CancelTaxButton setTitle:@"Cancel" forState:UIControlStateNormal];
            [NotesView addSubview:CancelNotesBtn];
        }
       
    }else if (selectedbtn==105){
        if (!StoresPopupView)
        StoresPopupView=[[UIView alloc]init];
        if (isLandScope) {
            StoresPopupView.frame=CGRectMake(0, 0, 1024, 768);
        }else{
            
            StoresPopupView.frame=CGRectMake(0, 0, 768, 1024);
        }
        [StoresPopupView setBackgroundColor:[UIColor colorWithRed:10.0f/255.0f green:10.0f/255.0f blue:10.0f/255.0f alpha:0.7f/1.0f]];
        [self.view addSubview:StoresPopupView];
        if (!StoresView)
        StoresView=[[UIView alloc] init];
        if (isLandScope) {
             StoresView.frame=CGRectMake(50, 50, StoresPopupView.frame.size.width-100, StoresPopupView.frame.size.height-150);
        }else{
             StoresView.frame=CGRectMake(50, 150, StoresPopupView.frame.size.width-100, StoresPopupView.frame.size.height-400);
        }
        [StoresView setBackgroundColor:[UIColor colorWithRed:0.0f green:74.0f/255.0f blue:132.0f/255.0f alpha:1.0f]];
        [StoresView.layer setBorderWidth:2.0];
        [StoresView.layer setBorderColor:[[UIColor whiteColor] CGColor]];
        [StoresPopupView addSubview:StoresView];
          if (!StoreDataArray)
        StoreDataArray=[[NSMutableArray alloc]init];
        
        NSString *querySQL5 = [NSString stringWithFormat: @"SELECT store_id FROM store_details"];
        NSMutableArray *storesArray=[[NSMutableArray alloc]init];
        [[DataBaseManager dataBaseManager]execute:querySQL5 resultsArray:storesArray];
        for (NSDictionary *myDict in storesArray)
        {
            [StoreDataArray addObject:[myDict objectForKey:@"store_id"]];
        }

        CGFloat widthfield4=(StoresView.frame.size.width)/4;
         if (!StoresTextlbl)
        StoresTextlbl=[[UILabel alloc] init];
        StoresTextlbl.frame=CGRectMake(widthfield4+100,10,widthfield4,40);
        [StoresTextlbl setFont:[UIFont systemFontOfSize:25.0f]];
        [StoresTextlbl setBackgroundColor:[UIColor clearColor]];
        [StoresTextlbl setTextColor:[UIColor whiteColor]];
        [StoresTextlbl setText:@"Store Details"];
        [StoresTextlbl setTextAlignment:NSTextAlignmentLeft];
        [StoresView addSubview:StoresTextlbl];
          if (!Storeslbl)
        Storeslbl=[[UILabel alloc] init];
        Storeslbl.frame=CGRectMake(20, 155,widthfield4+10, 40);
        [Storeslbl setFont:[UIFont systemFontOfSize:20.0f]];
        [Storeslbl setBackgroundColor:[UIColor clearColor]];
        [Storeslbl setTextColor:[UIColor whiteColor]];
        [Storeslbl setText:@"Add Store"];
        Storeslbl.lineBreakMode = NSLineBreakByWordWrapping;
        Storeslbl.numberOfLines = 2;
        [Storeslbl setTextAlignment:NSTextAlignmentLeft];
        [StoresView addSubview:Storeslbl];
        if (!StoresBtn)
        StoresBtn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
        StoresBtn.frame=CGRectMake(Storeslbl.frame.size.width-40, 150,widthfield4+10, 40);
        [StoresBtn addTarget:self action:@selector(AddstoreClicked) forControlEvents:UIControlEventTouchUpInside];
        [StoresBtn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
        [StoresBtn setBackgroundImage:[UIImage imageNamed:@"drop-down-icon.png"] forState:UIControlStateNormal];
        // [CancelTaxButton setTitle:@"Cancel" forState:UIControlStateNormal];
        [StoresView addSubview:StoresBtn];
        
         if (!StoresListTable)
        StoresListTable = [[UITableView alloc] initWithFrame:CGRectMake(Storeslbl.frame.size.width-40, 50,widthfield4+10, 100) style:UITableViewStylePlain];
        StoresListTable.backgroundColor=[UIColor whiteColor];
        StoresListTable.delegate = self;
        StoresListTable.dataSource = self;
        StoresListTable.scrollEnabled = YES;
        StoresListTable.hidden=YES;
        [StoresListTable.layer setBorderWidth: 1.0];
        [StoresListTable.layer setBorderColor:[[UIColor grayColor] CGColor]];
        [StoresView addSubview:StoresListTable];
        
        
        if (!StoresDataTable)
        StoresDataTable = [[UITableView alloc] initWithFrame:CGRectMake(50, 200,StoresView.frame.size.width-100, 300) style:UITableViewStylePlain];
        StoresDataTable.backgroundColor=[UIColor whiteColor];
        StoresDataTable.delegate = self;
        StoresDataTable.dataSource = self;
        StoresDataTable.scrollEnabled = YES;
       
        [StoresDataTable.layer setBorderWidth: 1.0];
        [StoresDataTable.layer setBorderColor:[[UIColor grayColor] CGColor]];
        [StoresView addSubview:StoresDataTable];
        @autoreleasepool {
            SavestoresBtn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
            
            SavestoresBtn.frame=CGRectMake(widthfield4+100,540,80,30);
            [SavestoresBtn addTarget:self action:@selector(SaveStores) forControlEvents:UIControlEventTouchUpInside];
            
            //[SaveTaxButton setTitle:@"Save" forState:UIControlStateNormal];
            [SavestoresBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
            [SavestoresBtn setBackgroundImage:[UIImage imageNamed:@"savegreenbutton.png"] forState:UIControlStateNormal];
            [StoresView addSubview:SavestoresBtn];
            
            CancelStoresBtn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
            
            CancelStoresBtn.frame=CGRectMake(widthfield4+230,540,80,30);
            [CancelStoresBtn addTarget:self action:@selector(CancelStores) forControlEvents:UIControlEventTouchUpInside];
            [CancelStoresBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
            [CancelStoresBtn setBackgroundImage:[UIImage imageNamed:@"cancelgreenbutton.png"] forState:UIControlStateNormal];
            // [CancelTaxButton setTitle:@"Cancel" forState:UIControlStateNormal];
            [StoresView addSubview:CancelStoresBtn];
        }
    }else if (selectedbtn==103){
        if (!HistoryPopupView)
        HistoryPopupView=[[UIView alloc]init];
        if (isLandScope) {
            HistoryPopupView.frame=CGRectMake(0, 0, 1024, 768);
        }else{
            
            HistoryPopupView.frame=CGRectMake(0, 0, 768, 1024);
        }
        [HistoryPopupView setBackgroundColor:[UIColor colorWithRed:10.0f/255.0f green:10.0f/255.0f blue:10.0f/255.0f alpha:0.7f/1.0f]];
        [self.view addSubview:HistoryPopupView];
         if (!HistoryView)
        HistoryView=[[UIView alloc] init];
        if (isLandScope){
            HistoryView.frame=CGRectMake(50, 100, HistoryPopupView.frame.size.width-100, HistoryPopupView.frame.size.height-200);
        }else{
            HistoryView.frame=CGRectMake(50, 150, HistoryPopupView.frame.size.width-100, HistoryPopupView.frame.size.height-400);
        }
        [HistoryView setBackgroundColor:[UIColor colorWithRed:0.0f green:74.0f/255.0f blue:132.0f/255.0f alpha:1.0f]];
        [HistoryView.layer setBorderWidth:2.0];
        [HistoryView.layer setBorderColor:[[UIColor whiteColor] CGColor]];
        [HistoryPopupView addSubview:HistoryView];

        CGFloat widthfield5=(HistoryView.frame.size.width)/4;
         if (!Historytextlbl)
        Historytextlbl=[[UILabel alloc] init];
        Historytextlbl.frame=CGRectMake(widthfield5+120,10,widthfield5,40);
        [Historytextlbl setFont:[UIFont systemFontOfSize:25.0f]];
        [Historytextlbl setBackgroundColor:[UIColor clearColor]];
        [Historytextlbl setTextColor:[UIColor whiteColor]];
        [Historytextlbl setText:@"History Details"];
        [Historytextlbl setTextAlignment:NSTextAlignmentLeft];
        [HistoryView addSubview:Historytextlbl];
        if (!SalesHistoryTable)
        SalesHistoryTable = [[UITableView alloc] initWithFrame:CGRectMake(10,60,HistoryView.frame.size.width-20, 400) style:UITableViewStylePlain];
        SalesHistoryTable.backgroundColor=[UIColor clearColor];
        SalesHistoryTable.delegate = self;
        SalesHistoryTable.dataSource = self;
        SalesHistoryTable.scrollEnabled = YES;
        [SalesHistoryTable.layer setBorderWidth: 1.0];
        [SalesHistoryTable.layer setBorderColor:[[UIColor grayColor] CGColor]];
        [HistoryView addSubview:SalesHistoryTable];
        if (!saveHistoryBtn)
        saveHistoryBtn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
        saveHistoryBtn.frame=CGRectMake(widthfield5+160,500,80,30);
        [saveHistoryBtn addTarget:self action:@selector(Savehistory) forControlEvents:UIControlEventTouchUpInside];
        //[SaveTaxButton setTitle:@"Save" forState:UIControlStateNormal];
        [saveHistoryBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
        [saveHistoryBtn setBackgroundImage:[UIImage imageNamed:@"savegreenbutton.png"] forState:UIControlStateNormal];
        [HistoryView addSubview:saveHistoryBtn];
      
    }
    }
    
}
-(void)Savehistory
{
    NSArray *StoresViewArray = HistoryView.subviews;
    for (int i = 0; i<[StoresViewArray count]; i++) {
        UIView *vi =[StoresViewArray objectAtIndex:i];
        [vi removeFromSuperview];
        vi = nil;
    }
    NSArray *StoresPopupViewArray = HistoryPopupView.subviews;
    for (int i = 0; i<[StoresPopupViewArray count]; i++) {
        UIView *vi =[StoresPopupViewArray objectAtIndex:i];
        [vi removeFromSuperview];
        vi = nil;
    }
    [HistoryView removeFromSuperview],[HistoryPopupView removeFromSuperview];
    [HistoryPopupView removeFromSuperview];
    
}
-(void)GeneralinfoFieldClicked:(UITextField *)sender
{
    NSInteger selected=sender.tag;
    if (selected == 100)
    {
        
        GCompanyName=sender.text;
    }
    if (selected == 101)
    {
        GStreetAddress=sender.text;
    }
    if (selected == 102)
    {
        GStreetAddress2=sender.text;
    }
    if (selected == 103)
    {
        
        Gcity=sender.text;
    }
    if (selected == 104)
    {
        
        GCountry=sender.text;
    }

}
-(void)GeneralinfoFieldClicked2:(UITextField *)sender
{
    NSInteger selected=sender.tag;
    if (selected == 100)
    {
        
        Gphone=sender.text;
    }
    if (selected == 101)
    {
        GAlternatePhone=sender.text;
    }
    if (selected == 102)
    {
        GBirthDay=sender.text;
    }
    if (selected == 103)
    {
        
        Gstate=sender.text;
    }
    if (selected == 104)
    {
        
        GpostalCode=sender.text;
    }
}
-(void)ExtendedinfoFieldClicked:(UITextField *)sender
{
    NSInteger selected=sender.tag;
    if (selected == 100)
    {
        
        CardNo=sender.text;
    }
    if (selected == 101)
    {
        Expiration=sender.text;
    }
}
-(void)ExtendedinfoFieldClicked2:(UITextField *)sender
{
    NSInteger selected=sender.tag;
    if (selected == 100)
    {
        
        LicenseId=sender.text;
    }
    if (selected == 101)
    {
        ExpDate=sender.text;
    }
    if (selected == 102)
    {
        MPhone=sender.text;
    }
    if (selected == 103)
    {
        
        Fax=sender.text;
    }
    
}

-(void)ShippinginfoFieldClicked:(UITextField *)sender
{
    NSInteger selected=sender.tag;
    if (selected == 100)
    {
        
        ShCompanyName=sender.text;
    }
    if (selected == 101)
    {
        ShStreetAddress=sender.text;
    }
    if (selected == 102)
    {
        ShStreetAddress2=sender.text;
    }
    if (selected == 103)
    {
        
       Shcity=sender.text;
    }
    if (selected == 104)
    {
        
        ShCountry=sender.text;
    }

}

-(void)ShippinginfoFieldClicked2:(UITextField *)sender
{
    NSInteger selected=sender.tag;
    if (selected == 100)
    {
        
        Shphone=sender.text;
    }
    if (selected == 101)
    {
        ShAlternatePhone=sender.text;
    }
    if (selected == 102)
    {
        ShBirthDay=sender.text;
    }
    if (selected == 103)
    {
        
        Shstate=sender.text;
    }
    if (selected == 104)
    {
        
        ShpostalCode=sender.text;
    }
}
-(void)SaveStores
{
    NSArray *sideArray = StoresView.subviews;
    for (int i = 0; i<[sideArray count]; i++) {
        UIView *vi =[sideArray objectAtIndex:i];
        [vi removeFromSuperview];
        vi = nil;
    }
    
    NSArray *navBarArray = StoresPopupView.subviews;
    for (int i = 0; i<[navBarArray count]; i++) {
        UIView *vi =[navBarArray objectAtIndex:i];
        [vi removeFromSuperview];
        vi = nil;
        
    }
    [StoresView removeFromSuperview],[StoresPopupView removeFromSuperview];
}
-(void)CancelStores
{
   
    NSArray *sideArray = StoresView.subviews;
    for (int i = 0; i<[sideArray count]; i++) {
        UIView *vi =[sideArray objectAtIndex:i];
        [vi removeFromSuperview];
        vi = nil;
    }
    
    NSArray *navBarArray = StoresPopupView.subviews;
    for (int i = 0; i<[navBarArray count]; i++) {
        UIView *vi =[navBarArray objectAtIndex:i];
        [vi removeFromSuperview];
        vi = nil;
        
    }
    [StoresView removeFromSuperview],[StoresPopupView removeFromSuperview];
}
-(void)SaveHistory
{
  
    NSArray *sideArray = HistoryView.subviews;
    for (int i = 0; i<[sideArray count]; i++) {
        UIView *vi =[sideArray objectAtIndex:i];
        [vi removeFromSuperview];
        vi = nil;
    }
    
    NSArray *navBarArray = HistoryPopupView.subviews;
    for (int i = 0; i<[navBarArray count]; i++) {
        UIView *vi =[navBarArray objectAtIndex:i];
        [vi removeFromSuperview];
        vi = nil;
        
    }
    [HistoryView removeFromSuperview], [HistoryPopupView removeFromSuperview];
}
-(void)CancelHistory
{
    NSArray *sideArray = HistoryView.subviews;
    for (int i = 0; i<[sideArray count]; i++) {
        UIView *vi =[sideArray objectAtIndex:i];
        [vi removeFromSuperview];
        vi = nil;
    }
    
    NSArray *navBarArray = HistoryPopupView.subviews;
    for (int i = 0; i<[navBarArray count]; i++) {
        UIView *vi =[navBarArray objectAtIndex:i];
        [vi removeFromSuperview];
        vi = nil;
        
    }
    [HistoryView removeFromSuperview], [HistoryPopupView removeFromSuperview];
}
-(void)AddstoreClicked
{
    if (StoresListTable.hidden==1){
        
        StoresListTable.hidden=NO;
    }else if (StoresListTable.hidden==0){
        [StoresListTable setHidden:YES];
    
    }
}
-(void)SaveGeneralInfoData
{
    NSArray *sideArray = GeneralInfoView.subviews;
    for (int i = 0; i<[sideArray count]; i++) {
        UIView *vi =[sideArray objectAtIndex:i];
        [vi removeFromSuperview];
        vi = nil;
    }
    
    NSArray *navBarArray = GeneralInfoPopUp.subviews;
    for (int i = 0; i<[navBarArray count]; i++) {
        UIView *vi =[navBarArray objectAtIndex:i];
        [vi removeFromSuperview];
        vi = nil;
        
    }
   [GeneralInfoView removeFromSuperview], [GeneralInfoPopUp removeFromSuperview];
    
}
-(void)CancelGeneralInfo
{
    NSArray *sideArray = GeneralInfoView.subviews;
    for (int i = 0; i<[sideArray count]; i++) {
        UIView *vi =[sideArray objectAtIndex:i];
        [vi removeFromSuperview];
        vi = nil;
    }
    
    NSArray *navBarArray = GeneralInfoPopUp.subviews;
    for (int i = 0; i<[navBarArray count]; i++) {
        UIView *vi =[navBarArray objectAtIndex:i];
        [vi removeFromSuperview];
        vi = nil;
        
    }
    [GeneralInfoView removeFromSuperview], [GeneralInfoPopUp removeFromSuperview];
}
-(void)SaveExtendedData
{
    NSArray *sideArray = ExtendedInfoView.subviews;
    for (int i = 0; i<[sideArray count]; i++) {
        UIView *vi =[sideArray objectAtIndex:i];
        [vi removeFromSuperview];
        vi = nil;
    }
    
    NSArray *navBarArray = ExtendedInfopopUp.subviews;
    for (int i = 0; i<[navBarArray count]; i++) {
        UIView *vi =[navBarArray objectAtIndex:i];
        [vi removeFromSuperview];
        vi = nil;
        
    }
    [ExtendedInfoView removeFromSuperview], [ExtendedInfopopUp removeFromSuperview];
}
-(void)CancelExtendedInfo
{
    NSArray *sideArray = ExtendedInfoView.subviews;
    for (int i = 0; i<[sideArray count]; i++) {
        UIView *vi =[sideArray objectAtIndex:i];
        [vi removeFromSuperview];
        vi = nil;
    }
    
    NSArray *navBarArray = ExtendedInfopopUp.subviews;
    for (int i = 0; i<[navBarArray count]; i++) {
        UIView *vi =[navBarArray objectAtIndex:i];
        [vi removeFromSuperview];
        vi = nil;
        
    }
    [ExtendedInfoView removeFromSuperview], [ExtendedInfopopUp removeFromSuperview];

}
-(void)SaveShippingData
{
   NSArray *sideArray = ShippingInfoView.subviews;
    for (int i = 0; i<[sideArray count]; i++) {
        UIView *vi =[sideArray objectAtIndex:i];
        [vi removeFromSuperview];
        vi = nil;
    }
    
    NSArray *navBarArray = ShippingInfoPopUp.subviews;
    for (int i = 0; i<[navBarArray count]; i++) {
        UIView *vi =[navBarArray objectAtIndex:i];
        [vi removeFromSuperview];
        vi = nil;
        
    }
    [ShippingInfoView removeFromSuperview], [ShippingInfoPopUp removeFromSuperview];

}
-(void)CancelShippingInfo
{
    NSArray *sideArray = ShippingInfoView.subviews;
    for (int i = 0; i<[sideArray count]; i++) {
        UIView *vi =[sideArray objectAtIndex:i];
        [vi removeFromSuperview];
        vi = nil;
    }
    
    NSArray *navBarArray = ShippingInfoPopUp.subviews;
    for (int i = 0; i<[navBarArray count]; i++) {
        UIView *vi =[navBarArray objectAtIndex:i];
        [vi removeFromSuperview];
        vi = nil;
        
    }
    [ShippingInfoView removeFromSuperview], [ShippingInfoPopUp removeFromSuperview];
}
-(void)CreditCardTypeclicked:(UIButton *)sender
{
    
        [sender resignFirstResponder];
        // Show you custom picker here....
    if (CreadidCardListTable.hidden==1){
        CreadidCardListTable.hidden=NO;
      
    }else if (CreadidCardListTable.hidden==0){
        [CreadidCardListTable setHidden:YES];
    }
    
    
}
-(void)SaveProductNotes
{
    CustomerNotes=NotesTextView.text;
   
    NSArray *sideArray = NotesView.subviews;
    for (int i = 0; i<[sideArray count]; i++) {
        UIView *vi =[sideArray objectAtIndex:i];
        [vi removeFromSuperview];
        vi = nil;
    }
    
    NSArray *navBarArray = NotesBackView.subviews;
    for (int i = 0; i<[navBarArray count]; i++) {
        UIView *vi =[navBarArray objectAtIndex:i];
        [vi removeFromSuperview];
        vi = nil;
        
    }
    [NotesView removeFromSuperview], [NotesBackView removeFromSuperview];
}
-(void)EditSaveCustomerNotes
{
    EditcustomerNotes=NotesTextView.text;
    NSArray *sideArray = NotesView.subviews;
    for (int i = 0; i<[sideArray count]; i++) {
        UIView *vi =[sideArray objectAtIndex:i];
        [vi removeFromSuperview];
        vi = nil;
    }
    
    NSArray *navBarArray = NotesBackView.subviews;
    for (int i = 0; i<[navBarArray count]; i++) {
        UIView *vi =[navBarArray objectAtIndex:i];
        [vi removeFromSuperview];
        vi = nil;
        
    }
    [NotesView removeFromSuperview], [NotesBackView removeFromSuperview];
}
-(void)NotesCancelclicked
{
    NSArray *sideArray = NotesView.subviews;
    for (int i = 0; i<[sideArray count]; i++) {
        UIView *vi =[sideArray objectAtIndex:i];
        [vi removeFromSuperview];
        vi = nil;
    }
    
    NSArray *navBarArray = NotesBackView.subviews;
    for (int i = 0; i<[navBarArray count]; i++) {
        UIView *vi =[navBarArray objectAtIndex:i];
        [vi removeFromSuperview];
        vi = nil;
        
    }
    [NotesView removeFromSuperview], [NotesBackView removeFromSuperview];
}

-(void)CancelCustomerData
{
    LastnameField.text=@"";
    FirstnameField.text=@"";
    EmailField.text=@"";
    CustomerField.text=@"";
}
#pragma mark - Save Customer Data Method
-(void)SaveCustomerData
{
    customerNO=CustomerField.text;
    NSString *querySQL = [NSString stringWithFormat: @"SELECT customer_no FROM customer_table"];
    NSMutableArray *customersArray=[[NSMutableArray alloc]init];
    [[DataBaseManager dataBaseManager]execute:querySQL resultsArray:customersArray];
    
    
    CustomerNosArray=[[NSMutableArray alloc]init];
    @autoreleasepool {
        for (NSDictionary *myDict in customersArray)
        {
            [CustomerNosArray addObject:[myDict objectForKey:@"customer_no"]];
        }
    }
  
   
    NSUInteger objIdx = [CustomerNosArray containsObject:CustomerField.text];
    // //NSLog(@"%lu",(unsigned long)objIdx);
    if(objIdx == 0)
    {
  
       NSString *CusinsertSQL =@"insert into customer_table (customer_no,customer_first_name,customer_last_name,customer_email,unique_id,created_timestamp,modified_timestamp,customer_notes) values(?,?,?,?,?,?,?,?)";
        
        NSMutableArray *insertCusArray=[[NSMutableArray alloc]initWithObjects:CustomerField.text,FirstnameField.text,LastnameField.text,EmailField.text,[generalDataObject  genRandStringLength:20],[generalDataObject getsystemDatetime],[generalDataObject getsystemDatetime],CustomerNotes, nil];
        [[DataBaseManager dataBaseManager]executeRecordsWithQuery:CusinsertSQL withArguments:insertCusArray];
        
          NSString *GeninsertSQL =@"insert into customer_general_info_table (customer_company_name,customer_primary_phone,customer_alternate_phone,customer_street1,customer_street2,customer_state,customer_city,customer_country,customer_zipcode,customer_birthday,customer_no,unique_id,created_timestamp,modified_timestamp) values(?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
        NSMutableArray *geninfoArray=[[NSMutableArray alloc]initWithObjects:GCompanyName,GStreetAddress,GStreetAddress2,Gcity,GCountry,Gphone,GAlternatePhone,GBirthDay,Gstate,GpostalCode,CustomerField.text,[generalDataObject  genRandStringLength:20],[generalDataObject getsystemDatetime],[generalDataObject getsystemDatetime], nil];
        [[DataBaseManager dataBaseManager]executeRecordsWithQuery:GeninsertSQL withArguments:geninfoArray];

        
         NSString *shpinsertSQL =@"insert into customer_shipping_table (shipping_first_name,shipping_company_name,shipping_street,shipping_city,shipping_country,shipping_last_name,shipping_phone,shipping_extended,shipping_state,shipping_zipcode,customer_no,unique_id,created_timestamp,modified_timestamp) values(?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
        
        NSMutableArray *shipArray=[[NSMutableArray alloc]initWithObjects:ShCompanyName,ShStreetAddress,ShStreetAddress2,Shcity,ShCountry,Shphone,ShAlternatePhone,ShBirthDay,Shstate,ShpostalCode,CustomerField.text,[generalDataObject  genRandStringLength:20],[generalDataObject getsystemDatetime],[generalDataObject getsystemDatetime], nil];
        [[DataBaseManager dataBaseManager]executeRecordsWithQuery:shpinsertSQL withArguments:shipArray];
        
        NSString *exdinsertSQL =@"insert into customer_extended_info_table (credit_card_num,expiration,credit_card_type,driving_license,exp_date,customer_mobile,customer_fax,customer_no,unique_id,created_timestamp,modified_timestamp) values(?,?,?,?,?,?,?,?,?,?,?)";
        NSMutableArray *exdArray=[[NSMutableArray alloc]initWithObjects:CardNo,Expiration,cardType,LicenseId,ExpDate,MPhone,Fax,CustomerField.text,[generalDataObject  genRandStringLength:20],[generalDataObject getsystemDatetime],[generalDataObject getsystemDatetime], nil];
        [[DataBaseManager dataBaseManager]executeRecordsWithQuery:exdinsertSQL withArguments:exdArray];
        
    
   
   
        for (int i=0; i<[SelectedStoredataArray count]; i++)
        {
             NSString *insertSQL;
             NSString *str=@"";
            str=[SelectedStoredataArray objectAtIndex:i];
            
            insertSQL =@"insert into customer_stores_table(customer_no, store_id,unique_id,created_timestamp,modified_timestamp) VALUES(?,?,?,?,?)";
                         
            NSMutableArray *storeArray=[[NSMutableArray alloc]initWithObjects:CustomerField.text,str,[generalDataObject  genRandStringLength:20],[generalDataObject getsystemDatetime],[generalDataObject getsystemDatetime], nil];
            [[DataBaseManager dataBaseManager]executeRecordsWithQuery:insertSQL withArguments:storeArray];
            
        }
GCompanyName=@"";GStreetAddress=@"";GStreetAddress2=@"";Gstate=@"";Gcity=@"";GCountry=@"";Gphone=@"";GpostalCode=@"";GAlternatePhone=@"";GBirthDay=@"";
      ShCompanyName=@"";ShStreetAddress=@"";ShStreetAddress2=@"";Shstate=@"";Shphone=@"";ShpostalCode=@"";Shcity=@"";ShCountry=@"";ShAlternatePhone=@""; ShBirthDay=@"";
         ExpDate=@"";Expiration=@"";cardType=@"";CardNo=@"";LicenseId=@"";MPhone=@"";Fax=@"";


        
//customer Data
        
        NSString *custquerySQL = [NSString stringWithFormat:@"SELECT customer_no,customer_first_name,customer_last_name,customer_email,unique_id,created_timestamp,modified_timestamp,customer_notes,server_local FROM customer_table WHERE customer_no='%@'",CustomerField.text];
        NSMutableArray *customersDataArray=[[NSMutableArray alloc]init];
        [[DataBaseManager dataBaseManager]execute:custquerySQL resultsArray:customersDataArray];
        
        NSMutableDictionary *CategoryDict=[[NSMutableDictionary alloc]init];
        [CategoryDict setObject:customersDataArray forKey:@"fields"];
        NSDictionary *jsonDict = [NSDictionary dictionaryWithDictionary:CategoryDict];
        
        
        NSError *err;
        
        NSData *jsonData = [NSJSONSerialization dataWithJSONObject:jsonDict options:kNilOptions error:&err];
        
        NSString *str=[[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];
        
        if(![generalDataObject  connectedToInternet]){
            
            NSString *insertSQL =@"insert into pending_queries (query_type,user_id,page_url,parameters,table_name,current_time) values(?,?,?,?,?,?)";
            NSMutableArray *pendingArray=[[NSMutableArray alloc]initWithObjects:@"INSERT",[generalDataObject  userID],@"saveinfo.php?",str,@"customer_table",[generalDataObject getsystemDatetime], nil];
            
            [[DataBaseManager dataBaseManager] executeRecordsWithQuery:insertSQL withArguments:pendingArray];
            
        }
        else if([generalDataObject  connectedToInternet]){
            
            if ([[generalDataObject  OriginalbaseURLstr] length]>0)
            {
            
            // //NSLog(@"%@",str);
            NSString *string=[NSString stringWithFormat:@"%@saveinfo.php?tablename=customer_table&systemtime=%@&userid=%@&sessionid=%@&data=%@",[generalDataObject  OriginalbaseURLstr],[[generalDataObject getsystemDatetime] stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding],[generalDataObject  userID],[generalDataObject  genRandStringLength:20],[str stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];
            
            // //NSLog(@"%@",str);
            
            NSURL *url=[NSURL URLWithString:string];
            NSMutableURLRequest *request = [[NSMutableURLRequest alloc] initWithURL:url];
            // //NSLog(@"%@",url);
            
            [request setHTTPMethod:@"POST"];
            [request setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
            //[request setValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"Content-Type"];
            
            
            
            CustomerConnection = [NSURLConnection connectionWithRequest:request delegate:self];
            
            [CustomerConnection start];
             }
        }
        
        
//General info Data
        
        NSString *genselectquerySQL = [NSString stringWithFormat: @"SELECT customer_company_name,customer_primary_phone,customer_alternate_phone,customer_street1,customer_street2,customer_state,customer_city,customer_country,customer_zipcode,customer_birthday,customer_no,unique_id,created_timestamp,modified_timestamp,server_local FROM customer_general_info_table WHERE customer_no='%@'",CustomerField.text];
        NSMutableArray *geninfoDataArray=[[NSMutableArray alloc]init];
        
        [[DataBaseManager dataBaseManager]execute:genselectquerySQL resultsArray:geninfoDataArray];
        
        NSMutableDictionary *CategoryDict2=[[NSMutableDictionary alloc]init];
        [CategoryDict2 setObject:geninfoDataArray forKey:@"fields"];
        NSDictionary *jsonDict2 = [NSDictionary dictionaryWithDictionary:CategoryDict2];
        
        
        NSError *err2;
        
        NSData *jsonData2 = [NSJSONSerialization dataWithJSONObject:jsonDict2 options:kNilOptions error:&err2];
        
        NSString *str2=[[NSString alloc] initWithData:jsonData2 encoding:NSUTF8StringEncoding];
        
        if(![generalDataObject  connectedToInternet]){
            
            NSString *insertSQL =@"insert into pending_queries (query_type,user_id,page_url,parameters,table_name,current_time) values(?,?,?,?,?,?)";
            NSMutableArray *pendingArray=[[NSMutableArray alloc]initWithObjects:@"INSERT",[generalDataObject  userID],@"saveinfo.php?",str2,@"customer_general_info_table",[generalDataObject getsystemDatetime], nil];
            
            [[DataBaseManager dataBaseManager] executeRecordsWithQuery:insertSQL withArguments:pendingArray];

            
        }
        else if([generalDataObject  connectedToInternet]){
            
            if ([[generalDataObject  OriginalbaseURLstr] length]>0)
            {
            // //NSLog(@"%@",str2);
            NSString *string=[NSString stringWithFormat:@"%@saveinfo.php?tablename=customer_general_info_table&systemtime=%@&userid=%@&sessionid=%@&data=%@",[generalDataObject  OriginalbaseURLstr],[[generalDataObject getsystemDatetime] stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding],[generalDataObject  userID],[generalDataObject  genRandStringLength:20],[str2 stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];
            
            
            
            NSURL *url=[NSURL URLWithString:string];
            NSMutableURLRequest *request = [[NSMutableURLRequest alloc] initWithURL:url];
            // //NSLog(@"%@",url);
            
            [request setHTTPMethod:@"POST"];
            [request setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
            //[request setValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"Content-Type"];
            
            
            
            GeneralInfoConnection = [NSURLConnection connectionWithRequest:request delegate:self];
            
            [GeneralInfoConnection start];
            }
        }
        
//Extended info Data
      
        NSString *exdselectquerySQL = [NSString stringWithFormat: @"SELECT credit_card_num,expiration,credit_card_type,driving_license,exp_date,customer_mobile,customer_fax,customer_no,unique_id,created_timestamp,modified_timestamp,server_local FROM customer_extended_info_table WHERE customer_no='%@'",CustomerField.text];
        NSMutableArray *exdinfoDataArray=[[NSMutableArray alloc]init];
        [[DataBaseManager dataBaseManager]execute:exdselectquerySQL resultsArray:exdinfoDataArray];

        
        NSMutableDictionary *CategoryDict3=[[NSMutableDictionary alloc]init];
        [CategoryDict3 setObject:exdinfoDataArray forKey:@"fields"];
        NSDictionary *jsonDict3 = [NSDictionary dictionaryWithDictionary:CategoryDict3];
        
        
        NSError *err3;
        
        NSData *jsonData3 = [NSJSONSerialization dataWithJSONObject:jsonDict3 options:kNilOptions error:&err3];
        
        NSString *str3=[[NSString alloc] initWithData:jsonData3 encoding:NSUTF8StringEncoding];
        
        if(![generalDataObject  connectedToInternet]){
            
            NSString *insertSQL =@"insert into pending_queries (query_type,user_id,page_url,parameters,table_name,current_time) values(?,?,?,?,?,?)";
            NSMutableArray *pendingArray=[[NSMutableArray alloc]initWithObjects:@"INSERT",[generalDataObject  userID],@"saveinfo.php?",str3,@"customer_extended_info_table",[generalDataObject getsystemDatetime], nil];
            
            [[DataBaseManager dataBaseManager] executeRecordsWithQuery:insertSQL withArguments:pendingArray];
            

            
        }
        else if([generalDataObject  connectedToInternet]){
            
            if ([[generalDataObject  OriginalbaseURLstr] length]>0)
            {
            
            // //NSLog(@"%@",str3);
            NSString *string=[NSString stringWithFormat:@"%@saveinfo.php?tablename=customer_extended_info_table&systemtime=%@&userid=%@&sessionid=%@&data=%@",[generalDataObject  OriginalbaseURLstr],[[generalDataObject getsystemDatetime] stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding],[generalDataObject  userID],[generalDataObject  genRandStringLength:20],[str3 stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];
            
            
            
            NSURL *url=[NSURL URLWithString:string];
            NSMutableURLRequest *request = [[NSMutableURLRequest alloc] initWithURL:url];
            // //NSLog(@"%@",url);
            
            [request setHTTPMethod:@"POST"];
            [request setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
            //[request setValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"Content-Type"];
            
            
            
            ExtendedConnection = [NSURLConnection connectionWithRequest:request delegate:self];
            
            [ExtendedConnection start];
            }
        }
    
//Shipping Info Data
    
      NSString *shpselectquerySQL = [NSString stringWithFormat: @"SELECT shipping_first_name,shipping_company_name,shipping_street,shipping_city,shipping_country,shipping_last_name,shipping_phone,shipping_extended,shipping_state,shipping_zipcode,customer_no,unique_id,created_timestamp,modified_timestamp,server_local FROM customer_shipping_table WHERE customer_no='%@'",CustomerField.text];
        NSMutableArray *shipingDataArray=[[NSMutableArray alloc]init];
        [[DataBaseManager dataBaseManager]execute:shpselectquerySQL resultsArray:shipingDataArray];
        
        NSMutableDictionary *CategoryDict4=[[NSMutableDictionary alloc]init];
        [CategoryDict4 setObject:shipingDataArray forKey:@"fields"];
        NSDictionary *jsonDict4 = [NSDictionary dictionaryWithDictionary:CategoryDict4];
        
        
        NSError *err4;
        
        NSData *jsonData4 = [NSJSONSerialization dataWithJSONObject:jsonDict4 options:kNilOptions error:&err4];
        
        NSString *str4=[[NSString alloc] initWithData:jsonData4 encoding:NSUTF8StringEncoding];
        
        if(![generalDataObject  connectedToInternet]){
            
            NSString *insertSQL =@"insert into pending_queries (query_type,user_id,page_url,parameters,table_name,current_time) values(?,?,?,?,?,?)";
            NSMutableArray *pendingArray=[[NSMutableArray alloc]initWithObjects:@"INSERT",[generalDataObject  userID],@"saveinfo.php?",str4,@"customer_shipping_table",[generalDataObject getsystemDatetime], nil];
            [[DataBaseManager dataBaseManager] executeRecordsWithQuery:insertSQL withArguments:pendingArray];
            
        }
        else if([generalDataObject  connectedToInternet]){
            
            if ([[generalDataObject  OriginalbaseURLstr] length]>0)
            {
            
            // //NSLog(@"%@",str4);
            NSString *string=[NSString stringWithFormat:@"%@saveinfo.php?tablename=customer_shipping_table&systemtime=%@&userid=%@&sessionid=%@&data=%@",[generalDataObject  OriginalbaseURLstr],[[generalDataObject getsystemDatetime] stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding],[generalDataObject  userID],[generalDataObject  genRandStringLength:20],[str4 stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];
            
            
            
            NSURL *url=[NSURL URLWithString:string];
            NSMutableURLRequest *request = [[NSMutableURLRequest alloc] initWithURL:url];
            // //NSLog(@"%@",url);
            
            [request setHTTPMethod:@"POST"];
            [request setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
            //[request setValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"Content-Type"];
            
            
            
            ShippingConnection = [NSURLConnection connectionWithRequest:request delegate:self];
            
            [ShippingConnection start];
            }
        }
      
  //Store Data
       
        NSString *storeselectquerySQL = [NSString stringWithFormat:@"SELECT customer_no, store_id,unique_id,created_timestamp,modified_timestamp,server_local FROM customer_stores_table WHERE customer_no='%@'",CustomerField.text];
        NSMutableArray *storesArray=[[NSMutableArray alloc]init];
        [[DataBaseManager dataBaseManager]execute:storeselectquerySQL resultsArray:storesArray];
        
        NSMutableDictionary *CategoryDict5=[[NSMutableDictionary alloc]init];
        [CategoryDict5 setObject:storesArray forKey:@"fields"];
        NSDictionary *jsonDict5 = [NSDictionary dictionaryWithDictionary:CategoryDict5];
        
        
        NSError *err5;
        
        NSData *jsonData5 = [NSJSONSerialization dataWithJSONObject:jsonDict5 options:kNilOptions error:&err5];
        
        NSString *str5=[[NSString alloc] initWithData:jsonData5 encoding:NSUTF8StringEncoding];
        
        if(![generalDataObject  connectedToInternet]){
            
            NSString *insertSQL =@"insert into pending_queries (query_type,user_id,page_url,parameters,table_name,current_time) values(?,?,?,?,?,?)";
            NSMutableArray *pendingArray=[[NSMutableArray alloc]initWithObjects:@"INSERT",[generalDataObject  userID],@"saveinfo.php?",str5,@"customer_stores_table",[generalDataObject getsystemDatetime], nil];
            [[DataBaseManager dataBaseManager] executeRecordsWithQuery:insertSQL withArguments:pendingArray];
        }
        else if([generalDataObject  connectedToInternet]){
            
            if ([[generalDataObject  OriginalbaseURLstr] length]>0)
            {
            
            // //NSLog(@"%@",str5);
            NSString *string=[NSString stringWithFormat:@"%@saveinfo.php?tablename=customer_stores_table&systemtime=%@&userid=%@&sessionid=%@&data=%@",[generalDataObject  OriginalbaseURLstr],[[generalDataObject getsystemDatetime] stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding],[generalDataObject  userID],[generalDataObject  genRandStringLength:20],[str5 stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];
            
            
            
            NSURL *url=[NSURL URLWithString:string];
            NSMutableURLRequest *request = [[NSMutableURLRequest alloc] initWithURL:url];
            // //NSLog(@"%@",url);
            
            [request setHTTPMethod:@"POST"];
            [request setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
            //[request setValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"Content-Type"];
            
            
            
            StoreConnection = [NSURLConnection connectionWithRequest:request delegate:self];
            
            [StoreConnection start];
            }
        }

        
        NSString *querySQL = [NSString stringWithFormat: @"SELECT customer_no,customer_first_name,customer_last_name,customer_email,customer_notes FROM customer_table"];
        NSMutableArray *customersArray=[[NSMutableArray alloc]init];
        [[DataBaseManager dataBaseManager]execute:querySQL resultsArray:customersArray];
        
        NSMutableArray *rdarray=customersArray;
        
        [customerPaginationObject  setCompleteresultset:rdarray];
        
        [customerPaginationObject   paginationinitializer:rdarray :20];
        
        [customerPaginationObject  paginationsegment].tintColor=[UIColor whiteColor];
        [[customerPaginationObject  paginationsegment] setFrame:CGRectMake(10, AddCustomerBtn.frame.size.height+10,CustomersBackView.frame.size.width-20, 40)];
        
        [[customerPaginationObject  paginationsegment] addTarget:self action:@selector(segmentchanged4:) forControlEvents:UIControlEventValueChanged];
        
        NSInteger selectedsegindex;
        selectedsegindex=0;
        [customerPaginationObject  paginationsegment].selectedSegmentIndex=selectedsegindex;
       [customerPaginationObject  activateResults:selectedsegindex];
       // [CustomersBackView addSubview:[customerPaginationObject  paginationsegment]];
        
        [EditCustomerTable reloadData];
        
        UIAlertView *alert=[[UIAlertView alloc] initWithTitle:@"Success" message:@"Customer Data Successfully saved" delegate:self cancelButtonTitle:@"ok" otherButtonTitles:Nil, nil];
        [alert show];
        
        CustomerField.text=@"";
        FirstnameField.text=@"";
        LastnameField.text=@"";
        EmailField.text=@"";
        
        SelectedStoredataArray=nil;
        SelectedStoredataArray=[[NSMutableArray alloc]init];
        
    }else{
        UIAlertView *alert=[[UIAlertView alloc] initWithTitle:@"message" message:@"Customer Number already exist change the Customer Number" delegate:self cancelButtonTitle:@"ok" otherButtonTitles:Nil, nil];
        [alert show];
        
    }
    

}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
   
   if (tableView==EditCustomerTable){
            if (indexPath.row==0)
            {
                
                return 40;
            }else{
                
                return 80;
              
            }
    
        }else if (tableView==SalesHistoryTable){
        if (indexPath.row==0){
            
            return 50;
        }else{
             return 80;
        
        }
        
    }else{
        return 40;
    }
    
}

- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section {
    // This will create a "invisible" footer
    return 0.01f;
}
- (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section
{
    return [UIView new];
    
    // If you are not using ARC:
    // return [[UIView new] autorelease];
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    if (tableView==CreadidCardListTable){
         return [CreditCardtypesArray count];
    }else if (tableView==StoresListTable){
        return [StoreDataArray count];
    }else if (tableView==StoresDataTable){
        return [SelectedStoredataArray count];
    }else if (tableView== EditCustomerTable){
        return [[customerPaginationObject  activeresultset] count]+1;
        
    }else if (tableView==SalesHistoryTable){
        return [itemIDArray count]+1;
    }
    return YES;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    if (tableView == EditCustomerTable){
        
        CustomerCell  *cell = (CustomerCell *)[tableView dequeueReusableCellWithIdentifier:@"CellIdentifier"];
        
        if(!cell) {
            [[NSBundle mainBundle] loadNibNamed:@"CustomerCell" owner:self options:nil];
            cell = customerCell;
        }
        
        // // //NSLog(@"Dict :-%@",dict);
        if (indexPath.row==0){
            cell.customer_TextView.text = @"Customer";
            cell.firstName_TextView.text =@"Firstname";
            cell.lastName_TextView.text =@"Lastname";
            cell.address_TextView.text =@"Address";
            cell.company_TextView.text =@"Company";
            cell.phone_TextView.text =@"Phone";
            
            cell.customer_TextView.textColor=[UIColor blackColor];
            cell.firstName_TextView.textColor=[UIColor blackColor];
            cell.lastName_TextView.textColor=[UIColor blackColor];
            cell.address_TextView.textColor=[UIColor blackColor];
            cell.company_TextView.textColor=[UIColor blackColor];
            cell.phone_TextView.textColor=[UIColor blackColor];
            cell.contentView.backgroundColor=[UIColor colorWithRed:200.0f/255.0f green:200.0f/255.0f blue:200.0f/255.0f alpha:1.0f];
            cell.edit_Button.hidden=YES;
            cell.delete_Button.hidden=YES;
            
        }else{
            
            cell.customer_TextView.text = [CustomerNosArray objectAtIndex:indexPath.row-1];
            cell.firstName_TextView.text =[CuFirstnamesArray objectAtIndex:indexPath.row-1];
            cell.lastName_TextView.text =[CuLastnamesArray objectAtIndex:indexPath.row-1];
            cell.address_TextView.text =[ShExdedArressArray objectAtIndex:indexPath.row-1];
            cell.company_TextView.text =[ShCompanynamesArray objectAtIndex:indexPath.row-1];
            cell.phone_TextView.text =[ShPhonenumbersArray objectAtIndex:indexPath.row-1];
            
            cell.customer_TextView.textColor=[UIColor whiteColor];
            cell.firstName_TextView.textColor=[UIColor whiteColor];
            cell.lastName_TextView.textColor=[UIColor whiteColor];
            cell.address_TextView.textColor=[UIColor whiteColor];
            cell.company_TextView.textColor=[UIColor whiteColor];
            cell.phone_TextView.textColor=[UIColor whiteColor];
            
            cell.edit_Button.hidden=NO;
            cell.delete_Button.hidden=NO;
            
            cell.edit_Button.tag=indexPath.row;
            cell.delete_Button.tag=indexPath.row;
            
          
            if (indexPath.row%2==0){
                
                cell.contentView.backgroundColor=[UIColor colorWithRed:64.0f/255.0f green:96.0f/255.0f blue:120.0f/255.0f alpha:1.0f];
            }else
            {
                cell.contentView.backgroundColor=[UIColor colorWithRed:56.0f/255.0f green:104.0f/255.0f blue:128.0f/255.0f alpha:1.0f];
                
            }
            
        }
      
        return cell;
        
    }else if (tableView == SalesHistoryTable){
        if (!SnosArray)
        SnosArray=[[NSMutableArray alloc]init];
        for (int i=1;i<=[itemIDArray count] ; i++)
        {
            [SnosArray  addObject:[NSString stringWithFormat:@"%d",i]];
            
        }
        CustomerHistoryCell  *cell = (CustomerHistoryCell *)[tableView dequeueReusableCellWithIdentifier:@"CellIdentifier"];
        
        if(!cell) {
            [[NSBundle mainBundle] loadNibNamed:@"CustomerHistoryCell" owner:self options:nil];
            cell = customerHistoryCell;
        }
        
        // // //NSLog(@"Dict :-%@",dict);
        if (indexPath.row==0){
            cell.sno_TextView.text=@"S.No";
            cell.itemID_TextView.text = @"ItemID";
            cell.Discount_TextView.text =@"Discount";
            cell.tax_TextView.text =@"Tax";
            cell.cost_TextView.text =@"Cost";
            cell.avgCost_TextView.text =@"AvgCost";
            cell.qty_TextView.text =@"Qty";
            cell.date_TextView.text =@"Date";
            
            
            cell.sno_TextView.textColor=[UIColor blackColor];
            cell.itemID_TextView.textColor=[UIColor blackColor];
            cell.Discount_TextView.textColor=[UIColor blackColor];
            cell.tax_TextView.textColor=[UIColor blackColor];
            cell.cost_TextView.textColor=[UIColor blackColor];
            cell.avgCost_TextView.textColor=[UIColor blackColor];
            cell.qty_TextView.textColor=[UIColor blackColor];
            cell.date_TextView.textColor=[UIColor blackColor];
          
            cell.contentView.backgroundColor=[UIColor colorWithRed:200.0f/255.0f green:200.0f/255.0f blue:200.0f/255.0f alpha:1.0f];
            
            
        }else{
            
            cell.sno_TextView.text = [SnosArray objectAtIndex:indexPath.row-1];
            cell.itemID_TextView.text = [itemIDArray objectAtIndex:indexPath.row-1];
            cell.Discount_TextView.text =[discountArray objectAtIndex:indexPath.row-1];
            cell.tax_TextView.text =[taxArray objectAtIndex:indexPath.row-1];
            cell.cost_TextView.text =[yourCostArray objectAtIndex:indexPath.row-1];
            cell.avgCost_TextView.text =[avgArray objectAtIndex:indexPath.row-1];
            cell.qty_TextView.text =[quantityArray objectAtIndex:indexPath.row-1];
            cell.date_TextView.text =[dateArray objectAtIndex:indexPath.row-1];
            
            cell.sno_TextView.textColor=[UIColor whiteColor];
            cell.itemID_TextView.textColor=[UIColor whiteColor];
            cell.Discount_TextView.textColor=[UIColor whiteColor];
            cell.tax_TextView.textColor=[UIColor whiteColor];
            cell.cost_TextView.textColor=[UIColor whiteColor];
            cell.avgCost_TextView.textColor=[UIColor whiteColor];
            cell.qty_TextView.textColor=[UIColor whiteColor];
            cell.date_TextView.textColor=[UIColor whiteColor];
            
            if (indexPath.row%2==0){
                
                cell.contentView.backgroundColor=[UIColor colorWithRed:64.0f/255.0f green:96.0f/255.0f blue:120.0f/255.0f alpha:1.0f];
            }else
            {
                cell.contentView.backgroundColor=[UIColor colorWithRed:56.0f/255.0f green:104.0f/255.0f blue:128.0f/255.0f alpha:1.0f];
                
            }
            
        }
        
        return cell;
        
    }else{
    static NSString *CellIdentifier = @"Cell";
    
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    
        if(!cell) {
           cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:nil];
        }
        if (tableView== CreadidCardListTable)
        {
            cell.textLabel.text=[CreditCardtypesArray objectAtIndex:indexPath.row];
            cell.textLabel.textAlignment=NSTextAlignmentCenter;
     
           
        }
    if ([StoreDataArray  count]>0)
    {
        if (tableView== StoresListTable)
        {
            cell.textLabel.text=[StoreDataArray objectAtIndex:indexPath.row];
            cell.textLabel.textAlignment=NSTextAlignmentCenter;
            
            
        }
    }
    if ([SelectedStoredataArray  count]>0)
    {
        if (tableView== StoresDataTable)
        {
            cell.textLabel.text=[SelectedStoredataArray objectAtIndex:indexPath.row];
            cell.textLabel.textAlignment=NSTextAlignmentCenter;
            cell.textLabel.textColor=[UIColor blackColor];
            
            DeleteStoreBtn=[UIButton buttonWithType:UIButtonTypeCustom];
            [DeleteStoreBtn setFrame:CGRectMake(300, 10, 25, 25)];
            //[editBtn setTitle:@"edit" forState:UIControlStateNormal];
            
            [DeleteStoreBtn setImage:[UIImage imageNamed:@"deleteicon.png"] forState:UIControlStateNormal];
            [DeleteStoreBtn addTarget:self action:@selector(DeleteStoreData:) forControlEvents:UIControlEventTouchUpInside];
            DeleteStoreBtn.tag=indexPath.row;
            [cell.contentView addSubview:DeleteStoreBtn];

            
            
        }
    }
      return cell;
 }
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
  
    if (tableView==CreadidCardListTable){
        
        CreadidCardListTable.hidden=YES;
        cardType=[CreditCardtypesArray objectAtIndex:indexPath.row];
        [CreditCardTypeBtn setTitle:cardType forState:UIControlStateNormal];
    }else if (tableView==StoresListTable){
        
        StoresListTable.hidden=YES;
        NSString *selectedstr=[StoreDataArray objectAtIndex:indexPath.row];
        [StoresBtn setTitle:selectedstr forState:UIControlStateNormal];
        
        if ([SelectedStoredataArray count]>0){
            NSUInteger objIdx = [SelectedStoredataArray containsObject:selectedstr];
            
            
            // //NSLog(@"%lu",(unsigned long)objIdx);
            if(objIdx == 0 ){
                
                  [SelectedStoredataArray addObject:selectedstr];
                  [StoresDataTable reloadData];
                
            }else{
                
                UIAlertView *alert=[[UIAlertView alloc] initWithTitle:@"message" message:@"Store already exist" delegate:self cancelButtonTitle:@"ok" otherButtonTitles:Nil, nil];
                [alert show];
            }
        }else{
             [SelectedStoredataArray addObject:selectedstr];
              [StoresDataTable reloadData];
        }
       
    }
}
- (IBAction)customer_editButtonClicked:(id)sender
{
    UIButton *but =sender;
    // //NSLog(@"EditButton %d",but.tag);
    NSInteger  selectedrow=but.tag-1;
    if (!EditCustomersBackView)
    EditCustomersBackView=[[UIView alloc]init];
    if (isLandScope) {
        EditCustomersBackView.frame=CGRectMake(0, 0, 1024, 768);
    }else{
        
        EditCustomersBackView.frame=CGRectMake(0, 0, 768, 1024);
    }
    [EditCustomersBackView setBackgroundColor:[UIColor colorWithRed:10.0f/255.0f green:10.0f/255.0f blue:10.0f/255.0f alpha:0.7f/1.0f]];
    [self.view addSubview:EditCustomersBackView];
    if (!EditAddCustomersView)
    EditAddCustomersView=[[UIScrollView alloc]init];
    if (isLandScope)
    {
        EditAddCustomersView.frame=CGRectMake(100, 150, EditCustomersBackView.frame.size.width-200, EditCustomersBackView.frame.size.height-350);
    }else{
        EditAddCustomersView.frame=CGRectMake(20, 200, EditCustomersBackView.frame.size.width-40, EditCustomersBackView.frame.size.height-650);
    }
    [EditAddCustomersView setBackgroundColor:[UIColor colorWithRed:0.0f green:74.0f/255.0f blue:132.0f/255.0f alpha:1.0f]];
    EditAddCustomersView.contentSize=CGSizeMake(EditCustomersBackView.frame.size.width-40, EditCustomersBackView.frame.size.height+100);
    [EditAddCustomersView.layer setBorderWidth:2.0];
    [EditAddCustomersView.layer setBorderColor:[[UIColor whiteColor] CGColor]];
    //AddvendorsView.layer.cornerRadius=8;
    [EditCustomersBackView addSubview:EditAddCustomersView];
    
    
    NSString *No=[CustomerNosArray objectAtIndex:selectedrow];
    NSString *fName=[CuFirstnamesArray objectAtIndex:selectedrow];
    NSString *Lname=[CuLastnamesArray objectAtIndex:selectedrow];
    NSString *mail=[EmailsArray objectAtIndex:selectedrow];
    EditcustomerNotes=[CustomerNotesArray objectAtIndex:selectedrow];
    
    NSString *querySQL1 = [NSString stringWithFormat: @"SELECT invoice_id,store_id,total_amt,status,payment_type,total_avgcost,total_profitt,unique_id,created_timestamp,holdid,employee,customer,cheque_no FROM invoice_total_table"];
    
    NSMutableArray *invItemsArray=[[NSMutableArray alloc]init];
    [[DataBaseManager dataBaseManager]execute:querySQL1 resultsArray:invItemsArray];
    
   
     if (!InvoiceIdsArray)
    InvoiceIdsArray=[[NSMutableArray alloc]init];
    @autoreleasepool {
        for ( NSDictionary *myDict in invItemsArray)
        {
            NSString *Customer=[myDict objectForKey:@"customer"];
            // //NSLog(@"%@",Customer);
            if ([Customer isEqualToString:No])
            {
                NSString *invoiceid=[myDict objectForKey:@"invoice_id"];
                selectedCuInvoiceId=invoiceid;
                [InvoiceIdsArray addObject:selectedCuInvoiceId];
            }
        }
    }
   
   
    itemIDArray = [[NSMutableArray alloc]init];
    itemNameArray = [[NSMutableArray alloc]init];
    discountArray = [[NSMutableArray alloc]init];
    taxArray = [[NSMutableArray alloc]init];
    yourCostArray = [[NSMutableArray alloc]init];
    avgArray = [[NSMutableArray alloc]init];
    quantityArray = [[NSMutableArray alloc]init];
    dateArray = [[NSMutableArray alloc]init];
    
    // //NSLog(@"%@",InvoiceIdsArray);
    if ([InvoiceIdsArray count]>0)
    {
        for (int i=0; i<[InvoiceIdsArray count]; i++)
        {
            
            NSString *InvoiceID=[InvoiceIdsArray objectAtIndex:i];
            NSString *querySQL2 = [NSString stringWithFormat: @"SELECT item_id, discount,total_tax,item_name,item_desscription,price_you_charge,avg_cost,item_quantity,invoice_id,payment_type,in_department,in_vendor,store_id,status,employee,customer FROM invoice_items_table WHERE invoice_id='%@'",InvoiceID];
            
            NSMutableArray *invitemsArray=[[NSMutableArray alloc]init];
            [[DataBaseManager dataBaseManager]execute:querySQL2 resultsArray:invitemsArray];
            
            @autoreleasepool {
                for (NSDictionary *myDict in invitemsArray)
                {
                   
                    NSString *itemId=[myDict objectForKey:@"item_id"];
                    NSString *itemName=[myDict objectForKey:@"item_name"];
                    NSString *discount=[myDict objectForKey:@"discount"];
                    NSString * tax= [myDict objectForKey:@"total_tax"];
                    NSString * yourCost= [myDict objectForKey:@"price_you_charge"];
                    NSString * avgCost= [myDict objectForKey:@"avg_cost"];
                    NSString * quantity = [myDict objectForKey:@"item_quantity"];
                    NSString * date= [myDict objectForKey:@"created_timestamp"];
                    
                    double pricevalue=[tax doubleValue];
                    NSString * SubTotalstr = [NSString stringWithFormat:@"%.02f", pricevalue];
                    [itemIDArray addObject:itemId];
                    [itemNameArray addObject:itemName];
                    [discountArray addObject:discount];
                    [taxArray addObject:SubTotalstr];
                    [yourCostArray addObject:yourCost];
                    [avgArray addObject:avgCost];
                    [quantityArray addObject:quantity];
                    [dateArray addObject:date];
                }

            }
            
        }
    }

    selectedCuInvoiceId=@"";
    
    EditGCompanyName=[GeneCompanyNamesArray objectAtIndex:selectedrow];
    EditGStreetAddress=[GeneStreetAddressArray objectAtIndex:selectedrow];
    EditGStreetAddress2=[GeneStaddress2Array objectAtIndex:selectedrow];
    
    EditGcity=[GeneCitysArray objectAtIndex:selectedrow];
    EditGCountry=[GeneCountrysArray objectAtIndex:selectedrow];
    EditGpostalCode=[GeneZipcodesArray objectAtIndex:selectedrow];
    EditGphone=[GenephoneArray objectAtIndex:selectedrow];
    EditGAlternatePhone=[GeneAleternatePhonesArray objectAtIndex:selectedrow];
    EditGBirthDay=[GeneBirthDaysArray objectAtIndex:selectedrow];
    EditGstate=[GeneStatesArray objectAtIndex:selectedrow];
    
    
    
    EditCardNo=[CardNosArray objectAtIndex:selectedrow];
    cardType=[CardtypesArray objectAtIndex:selectedrow];
    EditExpiration=[ExpirationsArray objectAtIndex:selectedrow];
    
    EditLicenseId=[LicensesArray objectAtIndex:selectedrow];
    EditExpDate=[ExpDatesArray objectAtIndex:selectedrow];
    EditMPhone=[MPhonesArray objectAtIndex:selectedrow];
    EditFax=[FaxesArray objectAtIndex:selectedrow];
    
    
    EditShCompanyName=[ShFirstnamesArray objectAtIndex:selectedrow];
    EditShStreetAddress=[ShCompanynamesArray objectAtIndex:selectedrow];
    EditShStreetAddress2=[ShStreetsArray objectAtIndex:selectedrow];
    
    EditShcity=[ShCitysArray objectAtIndex:selectedrow];
    EditShCountry=[ShCountrysArray objectAtIndex:selectedrow];
    
    EditShphone=[ShlastnamesArray objectAtIndex:selectedrow];
    EditShAlternatePhone=[ShPhonenumbersArray objectAtIndex:selectedrow];
    EditShstate=[ShSatesArray objectAtIndex:selectedrow];
    EditShBirthDay=[ShExdedArressArray objectAtIndex:selectedrow];
    EditShpostalCode=[ShZipcodesArray objectAtIndex:selectedrow];
    
    
   
  NSString *querySQL = [NSString stringWithFormat: @"SELECT store_id FROM customer_stores_table WHERE customer_no='%@'",No];
    NSMutableArray *cusStoreDataArray=[[NSMutableArray alloc]init];
    [[DataBaseManager dataBaseManager]execute:querySQL resultsArray:cusStoreDataArray];
   
        StoredataFromdatabaseArray=[[NSMutableArray alloc]init];
        SelectedStoredataArray=[[NSMutableArray alloc]init];
   
   
    @autoreleasepool {
        for (NSDictionary *myDict in cusStoreDataArray)
        {
            [StoredataFromdatabaseArray addObject:[myDict objectForKey:@"store_id"]];
        }
    }
    
    CGFloat EditcustomerW=(EditAddCustomersView.frame.size.width)/4;
    CGFloat Edit=(EditcustomerW/2)+20;
    if (!EditCustomerLbl)
    EditCustomerLbl=[[UILabel alloc] init];
    EditCustomerLbl.frame=CGRectMake(Edit-80, 30,EditcustomerW, 50);
    [EditCustomerLbl setFont:[UIFont systemFontOfSize:25.0f]];
    [EditCustomerLbl setBackgroundColor:[UIColor clearColor]];
    [EditCustomerLbl setTextColor:[UIColor whiteColor]];
    [EditCustomerLbl setText:@"Customer#"];
    EditCustomerLbl.lineBreakMode = NSLineBreakByWordWrapping;
    EditCustomerLbl.numberOfLines = 2;
    [EditCustomerLbl setTextAlignment:NSTextAlignmentLeft];
    [EditAddCustomersView addSubview:EditCustomerLbl];
    if (!EditCustomerField)
    EditCustomerField=[[UITextField alloc] init];
    //[nameTextfield setBorderStyle:UITextBorderStyleRoundedRect];
    EditCustomerField.frame=CGRectMake(EditcustomerW-5, 35,EditcustomerW, 40);
    EditCustomerField.delegate=self;
    UIView *paddingview=[[UIView alloc] initWithFrame:CGRectMake(5, 0, 5, 20)];
    // // //NSLog(@"%f",GeneralinfoField.frame.origin.y);
    EditCustomerField.leftView = paddingview;
    EditCustomerField.contentVerticalAlignment=UIControlContentVerticalAlignmentCenter;
    EditCustomerField.leftViewMode = UITextFieldViewModeAlways;
    [EditCustomerField setBackground:[UIImage imageNamed:@"addinputtextfield.png"]];
    EditCustomerField.text=No;
    [EditCustomerField setAutocorrectionType:UITextAutocorrectionTypeNo];
    [EditAddCustomersView addSubview:EditCustomerField];
    if (!EditLastnamelbl)
    EditLastnamelbl=[[UILabel alloc] init];
    EditLastnamelbl.frame=CGRectMake(Edit-80, 100,EditcustomerW, 50);
    [EditLastnamelbl setFont:[UIFont systemFontOfSize:25.0f]];
    [EditLastnamelbl setBackgroundColor:[UIColor clearColor]];
    [EditLastnamelbl setTextColor:[UIColor whiteColor]];
    [EditLastnamelbl setText:@"LastName"];
    EditLastnamelbl.lineBreakMode = NSLineBreakByWordWrapping;
    EditLastnamelbl.numberOfLines = 2;
    [EditLastnamelbl setTextAlignment:NSTextAlignmentLeft];
    [EditAddCustomersView addSubview:EditLastnamelbl];
    if (!EditLastnameField)
    EditLastnameField=[[UITextField alloc] init];
    //[nameTextfield setBorderStyle:UITextBorderStyleRoundedRect];
    EditLastnameField.frame=CGRectMake(EditcustomerW-5, 105,EditcustomerW, 40);
    EditLastnameField.delegate=self;
    UIView *paddingview2=[[UIView alloc] initWithFrame:CGRectMake(5, 0, 5, 20)];
    // // //NSLog(@"%f",GeneralinfoField.frame.origin.y);
    EditLastnameField.leftView = paddingview2;
    EditLastnameField.contentVerticalAlignment=UIControlContentVerticalAlignmentCenter;
    EditLastnameField.leftViewMode = UITextFieldViewModeAlways;
    [EditLastnameField setBackground:[UIImage imageNamed:@"addinputtextfield.png"]];
    EditLastnameField.text=Lname;
    [EditLastnameField setAutocorrectionType:UITextAutocorrectionTypeNo];
    EditLastnameField.autocapitalizationType=UITextAutocapitalizationTypeNone;
    [EditAddCustomersView addSubview:EditLastnameField];
    
     if (!Editfirstnamelbl)
    Editfirstnamelbl=[[UILabel alloc] init];
    Editfirstnamelbl.frame=CGRectMake(EditcustomerW+5+EditLastnameField.frame.size.width+10, 30,EditcustomerW, 50);
    
    [Editfirstnamelbl setFont:[UIFont systemFontOfSize:25.0f]];
    [Editfirstnamelbl setBackgroundColor:[UIColor clearColor]];
    [Editfirstnamelbl setTextColor:[UIColor whiteColor]];
    [Editfirstnamelbl setText:@"FirstName"];
    Editfirstnamelbl.lineBreakMode = NSLineBreakByWordWrapping;
    Editfirstnamelbl.numberOfLines = 2;
    [Editfirstnamelbl setTextAlignment:NSTextAlignmentLeft];
    [EditAddCustomersView addSubview:Editfirstnamelbl];
     if (!EditFirstnameField)
    EditFirstnameField=[[UITextField alloc] init];
    //[nameTextfield setBorderStyle:UITextBorderStyleRoundedRect];
    EditFirstnameField.frame=CGRectMake(EditcustomerW-15+EditLastnameField.frame.size.width+Editfirstnamelbl.frame.size.width, 35,EditcustomerW, 40);
    EditFirstnameField.delegate=self;
    UIView *paddingview3=[[UIView alloc] initWithFrame:CGRectMake(5, 0, 5, 20)];
    // // //NSLog(@"%f",GeneralinfoField.frame.origin.y);
    EditFirstnameField.leftView = paddingview3;
    EditFirstnameField.contentVerticalAlignment=UIControlContentVerticalAlignmentCenter;
    EditFirstnameField.leftViewMode = UITextFieldViewModeAlways;
    [EditFirstnameField setBackground:[UIImage imageNamed:@"addinputtextfield.png"]];
    EditFirstnameField.text=fName;
    [EditFirstnameField setAutocorrectionType:UITextAutocorrectionTypeNo];
    [EditAddCustomersView addSubview:EditFirstnameField];
      if (!EditEmaillbl)
    EditEmaillbl=[[UILabel alloc] init];
    EditEmaillbl.frame=CGRectMake(EditcustomerW+5+EditLastnameField.frame.size.width+10, 100,EditcustomerW, 50);
    [EditEmaillbl setFont:[UIFont systemFontOfSize:25.0f]];
    [EditEmaillbl setBackgroundColor:[UIColor clearColor]];
    [EditEmaillbl setTextColor:[UIColor whiteColor]];
    [EditEmaillbl setText:@"E-mail"];
    EditEmaillbl.lineBreakMode = NSLineBreakByWordWrapping;
    EditEmaillbl.numberOfLines = 2;
    [EditEmaillbl setTextAlignment:NSTextAlignmentLeft];
    [EditAddCustomersView addSubview:EditEmaillbl];
       if (!EditEmailField)
    EditEmailField=[[UITextField alloc] init];
    //[nameTextfield setBorderStyle:UITextBorderStyleRoundedRect];
    EditEmailField.frame=CGRectMake(EditcustomerW-15+EditLastnameField.frame.size.width+Editfirstnamelbl.frame.size.width, 105,EditcustomerW, 40);
    EditEmailField.delegate=self;
    UIView *paddingview4=[[UIView alloc] initWithFrame:CGRectMake(5, 0, 5, 20)];
    // // //NSLog(@"%f",GeneralinfoField.frame.origin.y);
    EditEmailField.leftView = paddingview4;
    EditEmailField.contentVerticalAlignment=UIControlContentVerticalAlignmentCenter;
    EditEmailField.leftViewMode = UITextFieldViewModeAlways;
    [EditEmailField setBackground:[UIImage imageNamed:@"addinputtextfield.png"]];
    EditEmailField.text=mail;
    [EditEmailField setAutocorrectionType:UITextAutocorrectionTypeNo];
    [EditAddCustomersView addSubview:EditEmailField];
    NSArray *array2;
    if (!array2)
    array2=[[NSArray alloc]initWithObjects:@"GeneralInfo",@"ExtentedInfo",@"Shipping",@"History",@"Notes",@"Stores",nil];
    CGFloat wdth=(EditAddCustomersView.frame.size.width)/7;
    CGFloat xvalue=wdth/4;
    for (int k=0; k<6; k++)
    {
        EditCustomerInfoBtn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
      
        [EditCustomerInfoBtn setTitle:[array2 objectAtIndex:k] forState:UIControlStateNormal];
        [EditCustomerInfoBtn setBackgroundImage:[UIImage imageNamed:@"additionaloptions.png"] forState:UIControlStateNormal];
        EditCustomerInfoBtn.frame=CGRectMake(xvalue-13,200,wdth+5, 40);
        
        [EditCustomerInfoBtn addTarget:self action:@selector(EditinfoButton1Clicked:) forControlEvents:UIControlEventTouchUpInside];
        EditCustomerInfoBtn.tag=k+100;
        [EditCustomerInfoBtn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
        
        [EditAddCustomersView addSubview:EditCustomerInfoBtn];
        xvalue=xvalue+wdth+12;
        
    }
    @autoreleasepool {
        EditSavecustomerBtn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
        
        EditSavecustomerBtn.frame=CGRectMake(EditcustomerW+100, 300, 80, 30);
        [EditSavecustomerBtn addTarget:self action:@selector(SaveEditCustomerData) forControlEvents:UIControlEventTouchUpInside];
        
        //[SaveTaxButton setTitle:@"Save" forState:UIControlStateNormal];
        [EditSavecustomerBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
        [EditSavecustomerBtn setBackgroundImage:[UIImage imageNamed:@"savegreenbutton.png"] forState:UIControlStateNormal];
        [EditAddCustomersView addSubview:EditSavecustomerBtn];
        
        EditCancelCustomerBtn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
        
        EditCancelCustomerBtn.frame=CGRectMake(EditcustomerW+220, 300, 80, 30);
        [EditCancelCustomerBtn addTarget:self action:@selector(CancelEditCustomerData) forControlEvents:UIControlEventTouchUpInside];
        [EditCancelCustomerBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
        [EditCancelCustomerBtn setBackgroundImage:[UIImage imageNamed:@"cancelgreenbutton.png"] forState:UIControlStateNormal];
        // [CancelTaxButton setTitle:@"Cancel" forState:UIControlStateNormal];
        [EditAddCustomersView addSubview:EditCancelCustomerBtn];
    }


}

- (IBAction)customer_deleteButtonClicked:(id)sender
{
    UIButton *but =sender;
    // //NSLog(@"EditButton %d",but.tag);
    SelectedCustomer=but.tag-1;
    deleteCustomerAlert=[[UIAlertView alloc]initWithTitle:@"Delete" message:@"Are you sure you want delete the Customer Data" delegate:self cancelButtonTitle:@"ok" otherButtonTitles:@"cancel", nil];
    [deleteCustomerAlert show];

}

-(void)SaveEditCustomerData
{
  customerNO=EditCustomerField.text;
    
    NSString *Customerupdatestr=@"UPDATE customer_table SET customer_first_name=?,customer_last_name=?,customer_email=?,customer_notes=? WHERE customer_no=?";
    
    NSMutableArray *updatecustArray=[[NSMutableArray alloc]initWithObjects:EditFirstnameField.text,EditLastnameField.text,EditEmailField.text,EditcustomerNotes,EditCustomerField.text, nil];
    [[DataBaseManager dataBaseManager]executeRecordsWithQuery:Customerupdatestr withArguments:updatecustArray];

    
    NSString *GeneralUpdatestr=@"UPDATE customer_general_info_table SET customer_company_name=?,customer_primary_phone=?,customer_alternate_phone=?,customer_street1=?,customer_street2=?,customer_state=?,customer_city=?,customer_country=?,customer_zipcode=?,customer_birthday=? WHERE customer_no=?";
    NSMutableArray *genArray=[[NSMutableArray alloc]initWithObjects:EditGCompanyName,EditGphone,EditGAlternatePhone,EditGStreetAddress,EditShStreetAddress2,EditGstate,EditGcity,EditGCountry,EditGpostalCode,EditGBirthDay,EditCustomerField.text, nil];
    [[DataBaseManager dataBaseManager]executeRecordsWithQuery:GeneralUpdatestr withArguments:genArray];
    
    
     NSString *ExtendedUpdatestr=@"UPDATE customer_extended_info_table SET credit_card_num=?,expiration=?,credit_card_type=?,driving_license=?,exp_date=?,customer_mobile=?,customer_fax=? WHERE customer_no=?";
    NSMutableArray *exdArray=[[NSMutableArray alloc]initWithObjects:EditCardNo,EditExpiration,cardType,EditLicenseId,EditExpDate,EditMPhone,EditFax,EditCustomerField.text, nil];
    [[DataBaseManager dataBaseManager]executeRecordsWithQuery:ExtendedUpdatestr withArguments:exdArray];
    
      NSString *ShippingUpdatestr=@"UPDATE customer_shipping_table SET shipping_first_name=?,shipping_company_name=?,shipping_street=?,shipping_city=?,shipping_country=?,shipping_last_name=?,shipping_phone=?,shipping_extended=?,shipping_state=?,shipping_zipcode=? WHERE customer_no=?";
    NSMutableArray *shippArray=[[NSMutableArray alloc]initWithObjects:EditShCompanyName,EditShStreetAddress,EditShStreetAddress2,EditShcity,EditShCountry,EditShphone,EditShAlternatePhone,EditShBirthDay,EditShstate,EditShpostalCode,EditCustomerField.text, nil];
    [[DataBaseManager dataBaseManager]executeRecordsWithQuery:ShippingUpdatestr withArguments:shippArray];
    
    
//customer Data

    NSString *custquerySQL = [NSString stringWithFormat:@"SELECT customer_no,customer_first_name,customer_last_name,customer_email,unique_id,created_timestamp,modified_timestamp,customer_notes,server_local FROM customer_table WHERE customer_no='%@'",EditCustomerField.text];
    NSMutableArray *customersDataArray=[[NSMutableArray alloc]init];
    [[DataBaseManager dataBaseManager]execute:custquerySQL resultsArray:customersDataArray];
    
    NSMutableDictionary *CategoryDict=[[NSMutableDictionary alloc]init];
    [CategoryDict setObject:customersDataArray forKey:@"fields"];
    NSDictionary *jsonDict = [NSDictionary dictionaryWithDictionary:CategoryDict];
    
    
    NSError *err;
    
    NSData *jsonData = [NSJSONSerialization dataWithJSONObject:jsonDict options:kNilOptions error:&err];
    
    NSString *str=[[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];
    
    if(![generalDataObject  connectedToInternet]){
        
       
        NSString *insertSQL =@"insert into pending_queries (query_type,user_id,page_url,parameters,table_name,current_time) values(?,?,?,?,?,?)";
        NSMutableArray *pendingArray=[[NSMutableArray alloc]initWithObjects:@"UPDATE",[generalDataObject  userID],@"saveinfo.php?",str,@"customer_table",[generalDataObject getsystemDatetime], nil];
        [[DataBaseManager dataBaseManager] executeRecordsWithQuery:insertSQL withArguments:pendingArray];
        
    }
    else if([generalDataObject  connectedToInternet]){
        
        if ([[generalDataObject  OriginalbaseURLstr] length]>0)
        {
        
        // //NSLog(@"%@",str);
        NSString *string=[NSString stringWithFormat:@"%@saveinfo.php?tablename=customer_table&systemtime=%@&userid=%@&sessionid=%@&data=%@&update=true",[generalDataObject  OriginalbaseURLstr],[[generalDataObject getsystemDatetime] stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding],[generalDataObject  userID],[generalDataObject  genRandStringLength:20],[str stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];
        
        // //NSLog(@"%@",str);
        
        NSURL *url=[NSURL URLWithString:string];
        NSMutableURLRequest *request = [[NSMutableURLRequest alloc] initWithURL:url];
        // //NSLog(@"%@",url);
        
        [request setHTTPMethod:@"POST"];
        [request setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
        //[request setValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"Content-Type"];
        
        
        
        CustomerConnection = [NSURLConnection connectionWithRequest:request delegate:self];
        
        [CustomerConnection start];
        }
    }
    
    
//General info Data
    

    NSString *genselectquerySQL = [NSString stringWithFormat: @"SELECT customer_company_name,customer_primary_phone,customer_alternate_phone,customer_street1,customer_street2,customer_state,customer_city,customer_country,customer_zipcode,customer_birthday,customer_no,unique_id,created_timestamp,modified_timestamp,server_local FROM customer_general_info_table WHERE customer_no='%@'",EditCustomerField.text];
    NSMutableArray *geninfoDataArray=[[NSMutableArray alloc]init];
    
    [[DataBaseManager dataBaseManager]execute:genselectquerySQL resultsArray:geninfoDataArray];
    
    NSMutableDictionary *CategoryDict2=[[NSMutableDictionary alloc]init];
    [CategoryDict2 setObject:geninfoDataArray forKey:@"fields"];
    NSDictionary *jsonDict2 = [NSDictionary dictionaryWithDictionary:CategoryDict2];
    
    
    NSError *err2;
    
    NSData *jsonData2 = [NSJSONSerialization dataWithJSONObject:jsonDict2 options:kNilOptions error:&err2];
    
    NSString *str2=[[NSString alloc] initWithData:jsonData2 encoding:NSUTF8StringEncoding];
    
    if(![generalDataObject  connectedToInternet]){
        
        NSString *insertSQL =@"insert into pending_queries (query_type,user_id,page_url,parameters,table_name,current_time) values(?,?,?,?,?,?)";
        NSMutableArray *pendingArray=[[NSMutableArray alloc]initWithObjects:@"UPDATE",[generalDataObject  userID],@"saveinfo.php?",str2,@"customer_general_info_table",[generalDataObject getsystemDatetime], nil];
        [[DataBaseManager dataBaseManager] executeRecordsWithQuery:insertSQL withArguments:pendingArray];

        
    }
    else if([generalDataObject  connectedToInternet]){
        if ([[generalDataObject  OriginalbaseURLstr] length]>0)
        {
        // //NSLog(@"%@",str2);
        NSString *string=[NSString stringWithFormat:@"%@saveinfo.php?tablename=customer_general_info_table&systemtime=%@&userid=%@&sessionid=%@&data=%@&update=true",[generalDataObject  OriginalbaseURLstr],[[generalDataObject getsystemDatetime] stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding],[generalDataObject  userID],[generalDataObject  genRandStringLength:20],[str2 stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];
        
        
        
        NSURL *url=[NSURL URLWithString:string];
        NSMutableURLRequest *request = [[NSMutableURLRequest alloc] initWithURL:url];
        // //NSLog(@"%@",url);
        
        [request setHTTPMethod:@"POST"];
        [request setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
        //[request setValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"Content-Type"];
        
        
        
        GeneralInfoConnection = [NSURLConnection connectionWithRequest:request delegate:self];
        
        [GeneralInfoConnection start];
        }
    }
    
//Extended info Data
    
    NSString *exdselectquerySQL = [NSString stringWithFormat: @"SELECT credit_card_num,expiration,credit_card_type,driving_license,exp_date,customer_mobile,customer_fax,customer_no,unique_id,created_timestamp,modified_timestamp,server_local FROM customer_extended_info_table WHERE customer_no='%@'",EditCustomerField.text];
    NSMutableArray *exdinfoDataArray=[[NSMutableArray alloc]init];
    [[DataBaseManager dataBaseManager]execute:exdselectquerySQL resultsArray:exdinfoDataArray];
    NSMutableDictionary *CategoryDict3=[[NSMutableDictionary alloc]init];
    [CategoryDict3 setObject:exdinfoDataArray forKey:@"fields"];
    NSDictionary *jsonDict3 = [NSDictionary dictionaryWithDictionary:CategoryDict3];
    
    
    NSError *err3;
    
    NSData *jsonData3 = [NSJSONSerialization dataWithJSONObject:jsonDict3 options:kNilOptions error:&err3];
    
    NSString *str3=[[NSString alloc] initWithData:jsonData3 encoding:NSUTF8StringEncoding];
    
    if(![generalDataObject  connectedToInternet]){
        
        NSString *insertSQL =@"insert into pending_queries (query_type,user_id,page_url,parameters,table_name,current_time) values(?,?,?,?,?,?)";
        NSMutableArray *pendingArray=[[NSMutableArray alloc]initWithObjects:@"UPDATE",[generalDataObject  userID],@"saveinfo.php?",str3,@"customer_extended_info_table",[generalDataObject getsystemDatetime], nil];
        [[DataBaseManager dataBaseManager] executeRecordsWithQuery:insertSQL withArguments:pendingArray];

        
    }
    else if([generalDataObject  connectedToInternet]){
        
        if ([[generalDataObject  OriginalbaseURLstr] length]>0)
        {
        
        // //NSLog(@"%@",str3);
        NSString *string=[NSString stringWithFormat:@"%@saveinfo.php?tablename=customer_extended_info_table&systemtime=%@&userid=%@&sessionid=%@&data=%@&update=true",[generalDataObject  OriginalbaseURLstr],[[generalDataObject getsystemDatetime] stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding],[generalDataObject  userID],[generalDataObject  genRandStringLength:20],[str3 stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];
        
        
        
        NSURL *url=[NSURL URLWithString:string];
        NSMutableURLRequest *request = [[NSMutableURLRequest alloc] initWithURL:url];
        // //NSLog(@"%@",url);
        
        [request setHTTPMethod:@"POST"];
        [request setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
        //[request setValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"Content-Type"];
        
        
        
        ExtendedConnection = [NSURLConnection connectionWithRequest:request delegate:self];
        
        [ExtendedConnection start];
        }
    }
    
//Shipping Info Data

    NSString *shpselectquerySQL = [NSString stringWithFormat: @"SELECT shipping_first_name,shipping_company_name,shipping_street,shipping_city,shipping_country,shipping_last_name,shipping_phone,shipping_extended,shipping_state,shipping_zipcode,customer_no,unique_id,created_timestamp,modified_timestamp,server_local FROM customer_shipping_table WHERE customer_no='%@'",EditCustomerField.text];
    NSMutableArray *shipingDataArray=[[NSMutableArray alloc]init];
    [[DataBaseManager dataBaseManager]execute:shpselectquerySQL resultsArray:shipingDataArray];
    
    NSMutableDictionary *CategoryDict4=[[NSMutableDictionary alloc]init];
    [CategoryDict4 setObject:shipingDataArray forKey:@"fields"];
    NSDictionary *jsonDict4 = [NSDictionary dictionaryWithDictionary:CategoryDict4];
    
    
    NSError *err4;
    
    NSData *jsonData4 = [NSJSONSerialization dataWithJSONObject:jsonDict4 options:kNilOptions error:&err4];
    
    NSString *str4=[[NSString alloc] initWithData:jsonData4 encoding:NSUTF8StringEncoding];
    
    if(![generalDataObject  connectedToInternet]){

        NSString *insertSQL =@"insert into pending_queries (query_type,user_id,page_url,parameters,table_name,current_time) values(?,?,?,?,?,?)";
        NSMutableArray *pendingArray=[[NSMutableArray alloc]initWithObjects:@"UPDATE",[generalDataObject  userID],@"saveinfo.php?",str4,@"customer_shipping_table",[generalDataObject getsystemDatetime], nil];
        [[DataBaseManager dataBaseManager] executeRecordsWithQuery:insertSQL withArguments:pendingArray];
        
    }
    else if([generalDataObject  connectedToInternet]){
        
        if ([[generalDataObject  OriginalbaseURLstr] length]>0)
        {
        // //NSLog(@"%@",str4);
        NSString *string=[NSString stringWithFormat:@"%@saveinfo.php?tablename=customer_shipping_table&systemtime=%@&userid=%@&sessionid=%@&data=%@&upate=true",[generalDataObject  OriginalbaseURLstr],[[generalDataObject getsystemDatetime] stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding],[generalDataObject  userID],[generalDataObject  genRandStringLength:20],[str4 stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];
        
        
        
        NSURL *url=[NSURL URLWithString:string];
        NSMutableURLRequest *request = [[NSMutableURLRequest alloc] initWithURL:url];
        // //NSLog(@"%@",url);
        
        [request setHTTPMethod:@"POST"];
        [request setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
        //[request setValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"Content-Type"];
        
        
        
        ShippingConnection = [NSURLConnection connectionWithRequest:request delegate:self];
        
        [ShippingConnection start];
        }
    }
    
//Store Data
    
    NSString *storeuniselectquerySQL = [NSString stringWithFormat:@"SELECT  unique_id FROM customer_stores_table WHERE customer_no='%@'",EditCustomerField.text];
    NSMutableArray *storesuniArray=[[NSMutableArray alloc]init];
    [[DataBaseManager dataBaseManager]execute:storeuniselectquerySQL resultsArray:storesuniArray];
    NSMutableArray *storeuniqueidsArray=[[NSMutableArray alloc]init];
    
    for (NSDictionary *Dict in storesuniArray) {
        
        [storeuniqueidsArray addObject:[Dict objectForKey:@"unique_id"]];
    }
    NSError *err6;
    
    NSData *jsonData6 = [NSJSONSerialization dataWithJSONObject:storeuniqueidsArray options:kNilOptions error:&err6];
    
    NSString *str6=[[NSString alloc] initWithData:jsonData6 encoding:NSUTF8StringEncoding];
    
    if(![generalDataObject  connectedToInternet]){
        
        NSString *insertSQL =@"insert into pending_queries (query_type,user_id,page_url,parameters,table_name,current_time) values(?,?,?,?,?,?)";
        NSMutableArray *pendingArray=[[NSMutableArray alloc]initWithObjects:@"DELETE",[generalDataObject  userID],@"deleteinfo.php?",str6,@"customer_stores_table",[generalDataObject getsystemDatetime], nil];
        [[DataBaseManager dataBaseManager] executeRecordsWithQuery:insertSQL withArguments:pendingArray];
        
    }
    else if([generalDataObject  connectedToInternet]){
        
        if ([[generalDataObject  OriginalbaseURLstr] length]>0)
        {
        
        // //NSLog(@"%@",str6);
        NSString *string=[NSString stringWithFormat:@"%@deleteinfo.php?tablename=customer_stores_table&systemtime=%@&userid=%@&sessionid=%@&unique_ids=%@",[generalDataObject  OriginalbaseURLstr],[[generalDataObject getsystemDatetime] stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding],[generalDataObject  userID],[generalDataObject  genRandStringLength:20],[str6 stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];
        
        
        
        NSURL *url=[NSURL URLWithString:string];
        NSMutableURLRequest *request = [[NSMutableURLRequest alloc] initWithURL:url];
        // //NSLog(@"%@",url);
        
        [request setHTTPMethod:@"POST"];
        [request setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
        //[request setValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"Content-Type"];
        
        
        
        StoreConnection = [NSURLConnection connectionWithRequest:request delegate:self];
        
        [StoreConnection start];
        }
    }

   NSString *updateSQL3 =@"DELETE FROM customer_stores_table WHERE customer_no=?";
    NSMutableArray *deletestoreArray=[[NSMutableArray alloc]initWithObjects:EditCustomerField.text, nil];
    [[DataBaseManager dataBaseManager]executeRecordsWithQuery:updateSQL3 withArguments:deletestoreArray];
                                     
    NSString *insertSQL;
    
    for (int i=0; i<[SelectedStoredataArray count]; i++)
    {
        NSString *str=[SelectedStoredataArray objectAtIndex:i];
        
        insertSQL =@"insert into customer_stores_table (customer_no, store_id,unique_id,created_timestamp,modified_timestamp) VALUES (?,?,?,?,?)";
        
        NSMutableArray *storeArray=[[NSMutableArray alloc]initWithObjects:EditCustomerField.text,str,[generalDataObject  genRandStringLength:20],[generalDataObject getsystemDatetime],[generalDataObject getsystemDatetime], nil];
        [[DataBaseManager dataBaseManager]executeRecordsWithQuery:insertSQL withArguments:storeArray];
        [storeArray removeAllObjects];
        
    }
    
    NSString *storeselectquerySQL = [NSString stringWithFormat:@"SELECT customer_no, store_id,unique_id,created_timestamp,modified_timestamp,server_local FROM customer_stores_table WHERE customer_no='%@'",EditCustomerField.text];
    NSMutableArray *storesArray=[[NSMutableArray alloc]init];
    [[DataBaseManager dataBaseManager]execute:storeselectquerySQL resultsArray:storesArray];
    
    NSMutableDictionary *CategoryDict5=[[NSMutableDictionary alloc]init];
    [CategoryDict5 setObject:storesArray forKey:@"fields"];
    NSDictionary *jsonDict5 = [NSDictionary dictionaryWithDictionary:CategoryDict5];
    
    
    NSError *err5;
    
    NSData *jsonData5 = [NSJSONSerialization dataWithJSONObject:jsonDict5 options:kNilOptions error:&err5];
    
    NSString *str5=[[NSString alloc] initWithData:jsonData5 encoding:NSUTF8StringEncoding];
    
    if(![generalDataObject  connectedToInternet]){
        
        NSString *insertSQL =@"insert into pending_queries (query_type,user_id,page_url,parameters,table_name,current_time) values(?,?,?,?,?,?)";
        NSMutableArray *pendingArray=[[NSMutableArray alloc]initWithObjects:@"INSERT",[generalDataObject  userID],@"saveinfo.php?",str5,@"customer_stores_table",[generalDataObject getsystemDatetime], nil];
        [[DataBaseManager dataBaseManager] executeRecordsWithQuery:insertSQL withArguments:pendingArray];
        
    }
    else if([generalDataObject  connectedToInternet]){
        
        if ([[generalDataObject  OriginalbaseURLstr] length]>0)
        {
        
        // //NSLog(@"%@",str5);
        NSString *string=[NSString stringWithFormat:@"%@saveinfo.php?tablename=customer_stores_table&systemtime=%@&userid=%@&sessionid=%@&data=%@",[generalDataObject  OriginalbaseURLstr],[[generalDataObject getsystemDatetime] stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding],[generalDataObject  userID],[generalDataObject  genRandStringLength:20],[str5 stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];
        
        
        
        NSURL *url=[NSURL URLWithString:string];
        NSMutableURLRequest *request = [[NSMutableURLRequest alloc] initWithURL:url];
        // //NSLog(@"%@",url);
        
        [request setHTTPMethod:@"POST"];
        [request setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
        //[request setValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"Content-Type"];
        
        
        
        StoreConnection = [NSURLConnection connectionWithRequest:request delegate:self];
        
        [StoreConnection start];
        }
    }
    
    UIAlertView *alert=[[UIAlertView alloc] initWithTitle:@"Success" message:@"Customer Data Successfully saved" delegate:self cancelButtonTitle:@"ok" otherButtonTitles:Nil, nil];
    [alert show];
    
    NSString *querySQL = [NSString stringWithFormat: @"SELECT customer_no,customer_first_name,customer_last_name,customer_email,customer_notes FROM customer_table"];
    NSMutableArray *customersArray=[[NSMutableArray alloc]init];
    [[DataBaseManager dataBaseManager]execute:querySQL resultsArray:customersArray];
    
    NSMutableArray *rdarray=customersArray;
    
    [customerPaginationObject  setCompleteresultset:rdarray];
    
    [customerPaginationObject   paginationinitializer:rdarray :20];
    
    [customerPaginationObject  paginationsegment].tintColor=[UIColor whiteColor];
    [[customerPaginationObject  paginationsegment] setFrame:CGRectMake(10, AddCustomerBtn.frame.size.height+10,CustomersBackView.frame.size.width-20, 40)];
    
    [[customerPaginationObject  paginationsegment] addTarget:self action:@selector(segmentchanged4:) forControlEvents:UIControlEventValueChanged];
    
    NSInteger selectedsegindex;
    selectedsegindex=0;
    [customerPaginationObject  paginationsegment].selectedSegmentIndex=selectedsegindex;
   [customerPaginationObject  activateResults:selectedsegindex];
    [CustomersBackView addSubview:[customerPaginationObject  paginationsegment]];
    [EditCustomersBackView removeFromSuperview];
    
      [self GetCustomerDataMethod];
    [EditCustomerTable reloadData];
    SelectedStoredataArray=Nil;
    cardType=@"";

}
-(void)CancelEditCustomerData
{
    [EditCustomersBackView removeFromSuperview];
}
-(void)EditinfoButton1Clicked:(UIButton *)sender
{
    NSInteger selectedbtn=sender.tag;
    
    if (selectedbtn==100)
    {
        if(!GeneralInfoPopUp)
        GeneralInfoPopUp=[[UIView alloc]init];
        if (isLandScope) {
            GeneralInfoPopUp.frame=CGRectMake(0, 0, 1024, 768);
        }else{
            
            GeneralInfoPopUp.frame=CGRectMake(0, 0, 768, 1024);
        }
        [GeneralInfoPopUp setBackgroundColor:[UIColor colorWithRed:10.0f/255.0f green:10.0f/255.0f blue:10.0f/255.0f alpha:0.7f/1.0f]];
        [self.view addSubview:GeneralInfoPopUp];
        
        GeneralInfoView=[[UIScrollView alloc] init];
        if (isLandScope){
            GeneralInfoView.frame=CGRectMake(50, 100, GeneralInfoPopUp.frame.size.width-100, GeneralInfoPopUp.frame.size.height-250);
              GeneralInfoView.contentSize=CGSizeMake(GeneralInfoPopUp.frame.size.width-100, GeneralInfoPopUp.frame.size.height);
        }else{
            GeneralInfoView.frame=CGRectMake(50, 150, GeneralInfoPopUp.frame.size.width-100, GeneralInfoPopUp.frame.size.height-500);
              GeneralInfoView.contentSize=CGSizeMake(GeneralInfoPopUp.frame.size.width-100, GeneralInfoPopUp.frame.size.height);
        }
        [GeneralInfoView setBackgroundColor:[UIColor colorWithRed:0.0f green:74.0f/255.0f blue:132.0f/255.0f alpha:1.0f]];
        [GeneralInfoView.layer setBorderWidth:2.0];
        [GeneralInfoView.layer setBorderColor:[[UIColor whiteColor] CGColor]];
        [GeneralInfoPopUp addSubview:GeneralInfoView];
        
        CGFloat fieldwidth=(GeneralInfoView.frame.size.width)/4;
        
        CGFloat o=(fieldwidth/2);
         if(!GeneralInfoTextlbl)
        GeneralInfoTextlbl=[[UILabel alloc] init];
        GeneralInfoTextlbl.frame=CGRectMake(fieldwidth+60, 10,fieldwidth+100, 40);
        [GeneralInfoTextlbl setFont:[UIFont systemFontOfSize:25.0f]];
        [GeneralInfoTextlbl setBackgroundColor:[UIColor clearColor]];
        [GeneralInfoTextlbl setTextColor:[UIColor whiteColor]];
        [GeneralInfoTextlbl setText:@"General Info Details"];
        [GeneralInfoTextlbl setTextAlignment:NSTextAlignmentLeft];
        [GeneralInfoView addSubview:GeneralInfoTextlbl];
        NSArray *labelArray;
        if (!labelArray)
        labelArray=[[NSArray alloc] initWithObjects:@"Company Name",@"Street Address ",@"Street Address2",@"City",@"Country",nil];
        int d=60;
        
        for (int i=0; i<5; i++)
        {
            
            GeneralInfolbl=[[UILabel alloc] init];
            GeneralInfolbl.frame=CGRectMake(o-60, d,fieldwidth+10, 40);
            
            GeneralInfolbl.tag=i+100;
            [GeneralInfolbl setFont:[UIFont systemFontOfSize:20.0f]];
            [GeneralInfolbl setBackgroundColor:[UIColor clearColor]];
            [GeneralInfolbl setTextColor:[UIColor whiteColor]];
           
            [GeneralInfolbl setText:[labelArray objectAtIndex:i]];
            [GeneralInfolbl setTextAlignment:NSTextAlignmentLeft];
            [GeneralInfoView addSubview:GeneralInfolbl];
            //// //NSLog(@"%f",generalinfolbl.frame.origin.y);
            GeneralInfoField=[[UITextField alloc] init];
            //[nameTextfield setBorderStyle:UITextBorderStyleRoundedRect];
            GeneralInfoField.frame=CGRectMake(GeneralInfolbl.frame.size.width+5, d,fieldwidth-10, 40);
            GeneralInfoField.delegate=self;
            GeneralInfoField.tag=i+100;
            
            UIView *paddingview=[[UIView alloc] initWithFrame:CGRectMake(5, 0, 5, 20)];
            // // //NSLog(@"%f",GeneralinfoField.frame.origin.y);
            GeneralInfoField.leftView = paddingview;
            GeneralInfoField.contentVerticalAlignment=UIControlContentVerticalAlignmentCenter;
            GeneralInfoField.leftViewMode = UITextFieldViewModeAlways;
            [GeneralInfoField setBackground:[UIImage imageNamed:@"addinputtextfield.png"]];
            
            if (GeneralInfoField.tag==100)
            {
                GeneralInfoField.text=EditGCompanyName;
            }
            if (GeneralInfoField.tag==101)
            {
                GeneralInfoField.text=EditGStreetAddress;
            }
            if (GeneralInfoField.tag==102)
            {
                GeneralInfoField.text=EditGStreetAddress2;
            }
            if (GeneralInfoField.tag==103)
            {
                GeneralInfoField.text=EditGcity;
            }
            if (GeneralInfoField.tag==104)
            {
                GeneralInfoField.text=EditGCountry;
            }
            [GeneralInfoField addTarget:self action:@selector(EditGeneralinfoFieldClicked:) forControlEvents:UIControlEventEditingDidEnd];
            [GeneralInfoField setAutocorrectionType:UITextAutocorrectionTypeNo];
            
            //[dataField addTarget:self action:@selector(adddata:) forControlEvents:UIControlEventTouchUpInside];
            
            [GeneralInfoView addSubview:GeneralInfoField];
            
            d=d+60;
            paddingview=nil;
        }
        NSArray *labelArray2;
        if (!labelArray2)
        labelArray2=[[NSArray alloc] initWithObjects:@"Primary Phone#",@"Alertnate Phone",@"Birthday",@"State",@"Zipcode",nil];
        
        int b=60;
        
        for (int i=0; i<5; i++)
        {
            
            GeneralInfolbl2=[[UILabel alloc] init];
            GeneralInfolbl2.frame=CGRectMake(GeneralInfolbl.frame.size.width+5+GeneralInfoField.frame.size.width+5, b,fieldwidth+10, 40);
            GeneralInfolbl2.tag=i+100;
            [GeneralInfolbl2 setFont:[UIFont systemFontOfSize:20.0f]];
            [GeneralInfolbl2 setBackgroundColor:[UIColor clearColor]];
            [GeneralInfolbl2 setTextColor:[UIColor whiteColor]];
            [GeneralInfolbl2 setText:[labelArray2 objectAtIndex:i]];
            [GeneralInfolbl2 setTextAlignment:NSTextAlignmentLeft];
            [GeneralInfoView addSubview:GeneralInfolbl2];
            //// //NSLog(@"%f",generalinfolbl.frame.origin.y);
            GeneralInfoField2=[[UITextField alloc] init];
            //[nameTextfield setBorderStyle:UITextBorderStyleRoundedRect];
            GeneralInfoField2.frame=CGRectMake(GeneralInfolbl.frame.size.width+GeneralInfoField.frame.size.width+GeneralInfolbl2.frame.size.width-5, b,fieldwidth-10, 40);
            GeneralInfoField2.delegate=self;
            GeneralInfoField2.tag=i+100;
            
            UIView *paddingview=[[UIView alloc] initWithFrame:CGRectMake(5, 0, 5, 20)];
            // // //NSLog(@"%f",GeneralinfoField.frame.origin.y);
            GeneralInfoField2.leftView = paddingview;
            GeneralInfoField2.contentVerticalAlignment=UIControlContentVerticalAlignmentCenter;
            GeneralInfoField2.leftViewMode = UITextFieldViewModeAlways;
            
            [GeneralInfoField2 setBackground:[UIImage imageNamed:@"addinputtextfield.png"]];
            if (GeneralInfoField2.tag==100)
            {
                GeneralInfoField2.text=EditGphone;
            }
            if (GeneralInfoField2.tag==101)
            {
                GeneralInfoField2.text=EditGAlternatePhone;
            }
            if (GeneralInfoField2.tag==102)
            {
                GeneralInfoField2.text=EditGBirthDay;
            }
            if (GeneralInfoField2.tag==103)
            {
                GeneralInfoField2.text=EditGstate;
            }
            if (GeneralInfoField2.tag==104)
            {
                GeneralInfoField2.text=EditGpostalCode;
            }
            [GeneralInfoField2 addTarget:self action:@selector(EditGeneralinfoFieldClicked2:) forControlEvents:UIControlEventEditingDidEnd];
            [GeneralInfoField2 setAutocorrectionType:UITextAutocorrectionTypeNo];
            
            //[dataField addTarget:self action:@selector(adddata:) forControlEvents:UIControlEventTouchUpInside];
            
            [GeneralInfoView addSubview:GeneralInfoField2];
            
            b=b+60;
            paddingview=nil;
            
        }
        
        @autoreleasepool {
            SaveGeneralInfoBtn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
            
            SaveGeneralInfoBtn.frame=CGRectMake(fieldwidth+80, 400, 80, 30);
            [SaveGeneralInfoBtn addTarget:self action:@selector(SaveGeneralInfoData) forControlEvents:UIControlEventTouchUpInside];
            
            //[SaveTaxButton setTitle:@"Save" forState:UIControlStateNormal];
            [SaveGeneralInfoBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
            [SaveGeneralInfoBtn setBackgroundImage:[UIImage imageNamed:@"savegreenbutton.png"] forState:UIControlStateNormal];
            [GeneralInfoView addSubview:SaveGeneralInfoBtn];
            
            CancelGeneralInfoBtn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
            
            CancelGeneralInfoBtn.frame=CGRectMake(fieldwidth+240, 400, 80, 30);
            [CancelGeneralInfoBtn addTarget:self action:@selector(CancelGeneralInfo) forControlEvents:UIControlEventTouchUpInside];
            [CancelGeneralInfoBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
            [CancelGeneralInfoBtn setBackgroundImage:[UIImage imageNamed:@"cancelgreenbutton.png"] forState:UIControlStateNormal];
            // [CancelTaxButton setTitle:@"Cancel" forState:UIControlStateNormal];
            [GeneralInfoView addSubview:CancelGeneralInfoBtn];
        }
     
        
        
    }else if (selectedbtn==101){
        if (!ExtendedInfopopUp)
        ExtendedInfopopUp=[[UIView alloc]init];
        if (isLandScope) {
            ExtendedInfopopUp.frame=CGRectMake(0, 0, 1024, 768);
        }else{
            
            ExtendedInfopopUp.frame=CGRectMake(0, 0, 768, 1024);
        }
        [ExtendedInfopopUp setBackgroundColor:[UIColor colorWithRed:10.0f/255.0f green:10.0f/255.0f blue:10.0f/255.0f alpha:0.7f/1.0f]];
        [self.view addSubview:ExtendedInfopopUp];
         if (!ExtendedInfoView)
        ExtendedInfoView=[[UIScrollView alloc] init];
        if (isLandScope) {
            ExtendedInfoView.frame=CGRectMake(50, 100, ExtendedInfopopUp.frame.size.width-100, ExtendedInfopopUp.frame.size.height-250);
            ExtendedInfoView.contentSize=CGSizeMake(ExtendedInfopopUp.frame.size.width-100, ExtendedInfopopUp.frame.size.height);
        }else{
            ExtendedInfoView.frame=CGRectMake(50, 150, ExtendedInfopopUp.frame.size.width-100, ExtendedInfopopUp.frame.size.height-500);
            ExtendedInfoView.contentSize=CGSizeMake(ExtendedInfopopUp.frame.size.width-100, ExtendedInfopopUp.frame.size.height);
        }
        [ExtendedInfoView setBackgroundColor:[UIColor colorWithRed:0.0f green:74.0f/255.0f blue:132.0f/255.0f alpha:1.0f]];
        
        [ExtendedInfoView.layer setBorderWidth:2.0];
        [ExtendedInfoView.layer setBorderColor:[[UIColor whiteColor] CGColor]];
        [ExtendedInfopopUp addSubview:ExtendedInfoView];
        
        CGFloat Efieldwidth=(ExtendedInfoView.frame.size.width)/4;
        
        CGFloat E=(Efieldwidth/2);
         if (!ExdInfotextlbl)
        ExdInfotextlbl=[[UILabel alloc] init];
        ExdInfotextlbl.frame=CGRectMake(Efieldwidth+60, 10,Efieldwidth+100, 40);
        [ExdInfotextlbl setFont:[UIFont systemFontOfSize:25.0f]];
        [ExdInfotextlbl setBackgroundColor:[UIColor clearColor]];
        [ExdInfotextlbl setTextColor:[UIColor whiteColor]];
       [ExdInfotextlbl setText:@"Extended Info Details"];
        [ExdInfotextlbl setTextAlignment:NSTextAlignmentLeft];
        [ExtendedInfoView addSubview:ExdInfotextlbl];
         if (!CreditcardInfolbl)
        CreditcardInfolbl=[[UILabel alloc] init];
        CreditcardInfolbl.frame=CGRectMake(Efieldwidth-40, 50,Efieldwidth+50, 40);
        [CreditcardInfolbl setFont:[UIFont systemFontOfSize:20.0f]];
        [CreditcardInfolbl setBackgroundColor:[UIColor clearColor]];
        [CreditcardInfolbl setTextColor:[UIColor whiteColor]];
        [CreditcardInfolbl setText:@"CreditCard Info"];
        [CreditcardInfolbl setTextAlignment:NSTextAlignmentLeft];
        [ExtendedInfoView addSubview:CreditcardInfolbl];
         if (!CreditCardtypesArray)
       CreditCardtypesArray=[[NSArray alloc]initWithObjects:@"Visa",@"Master card",@"American Express",@"Discover Card",@"JCB",@"DINERS CLUB INTERNATIONAL", nil];
          if (!PersonalInfolbl)
        PersonalInfolbl=[[UILabel alloc] init];
        PersonalInfolbl.frame=CGRectMake(Efieldwidth+CreditcardInfolbl.frame.size.width+40, 50,Efieldwidth+100, 40);
        [PersonalInfolbl setFont:[UIFont systemFontOfSize:20.0f]];
        [PersonalInfolbl setBackgroundColor:[UIColor clearColor]];
        [PersonalInfolbl setTextColor:[UIColor whiteColor]];
        [PersonalInfolbl setText:@"Personal Info"];
        [PersonalInfolbl setTextAlignment:NSTextAlignmentLeft];
        [ExtendedInfoView addSubview:PersonalInfolbl];
        NSArray *labelArray;
        if (!labelArray)
        labelArray=[[NSArray alloc] initWithObjects:@"CreditCardNumber",@"Expiration",nil];
        
        int d=100;
        
        for (int i=0; i<2; i++)
        {
            
            ExtendedInfolbl=[[UILabel alloc] init];
            ExtendedInfolbl.frame=CGRectMake(E-70, d,Efieldwidth+10, 40);
            ExtendedInfolbl.tag=i+100;
            [ExtendedInfolbl setFont:[UIFont systemFontOfSize:20.0f]];
            [ExtendedInfolbl setBackgroundColor:[UIColor clearColor]];
            [ExtendedInfolbl setTextColor:[UIColor whiteColor]];
            [ExtendedInfolbl setText:[labelArray objectAtIndex:i]];
            ExtendedInfolbl.lineBreakMode = NSLineBreakByWordWrapping;
            ExtendedInfolbl.numberOfLines = 2;
            [ExtendedInfolbl setTextAlignment:NSTextAlignmentLeft];
            [ExtendedInfoView addSubview:ExtendedInfolbl];
            //// //NSLog(@"%f",generalinfolbl.frame.origin.y);
            ExtendedField=[[UITextField alloc] init];
            //[nameTextfield setBorderStyle:UITextBorderStyleRoundedRect];
            ExtendedField.frame=CGRectMake(ExtendedInfolbl.frame.size.width+5, d,Efieldwidth-10, 40);
            ExtendedField.delegate=self;
            ExtendedField.tag=i+100;
            
            UIView *paddingview=[[UIView alloc] initWithFrame:CGRectMake(5, 0, 5, 20)];
            // // //NSLog(@"%f",GeneralinfoField.frame.origin.y);
            ExtendedField.leftView = paddingview;
            ExtendedField.contentVerticalAlignment=UIControlContentVerticalAlignmentCenter;
            ExtendedField.leftViewMode = UITextFieldViewModeAlways;
            [ExtendedField setBackground:[UIImage imageNamed:@"addinputtextfield.png"]];
            if (ExtendedField.tag==100)
            {
                ExtendedField.text=EditCardNo;
                
            }
            if (ExtendedField.tag==101)
            {
                ExtendedField.text=EditExpiration;
                
            }
            
            [ExtendedField addTarget:self action:@selector(EditExtendedinfoFieldClicked:) forControlEvents:UIControlEventEditingDidEnd];
            [ExtendedField setAutocorrectionType:UITextAutocorrectionTypeNo];
            
            
            //[dataField addTarget:self action:@selector(adddata:) forControlEvents:UIControlEventTouchUpInside];
            
            [ExtendedInfoView addSubview:ExtendedField];
            
            d=d+70;
            paddingview=nil;
            
        }
        // //NSLog(@"%d",d);
        if (!CreditCardtypelbl)
        CreditCardtypelbl=[[UILabel alloc] init];
        CreditCardtypelbl.frame=CGRectMake(E-70, 240,Efieldwidth+10, 40);
        [CreditCardtypelbl setFont:[UIFont systemFontOfSize:20.0f]];
        [CreditCardtypelbl setBackgroundColor:[UIColor clearColor]];
        [CreditCardtypelbl setTextColor:[UIColor whiteColor]];
        [CreditCardtypelbl setText:@"Credit Card Type"];
        CreditCardtypelbl.lineBreakMode = NSLineBreakByWordWrapping;
        CreditCardtypelbl.numberOfLines = 2;
        [CreditCardtypelbl setTextAlignment:NSTextAlignmentLeft];
        [ExtendedInfoView addSubview:CreditCardtypelbl];
         if (!CreditCardTypeBtn)
        CreditCardTypeBtn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
        
        CreditCardTypeBtn.frame=CGRectMake(ExtendedInfolbl.frame.size.width+5, 240,Efieldwidth-10, 40);
        [CreditCardTypeBtn addTarget:self action:@selector(CreditCardTypeclicked:) forControlEvents:UIControlEventTouchUpInside];
        [CreditCardTypeBtn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
        [CreditCardTypeBtn setBackgroundImage:[UIImage imageNamed:@"drop-down-icon.png"] forState:UIControlStateNormal];
       
        [CreditCardTypeBtn setTitle:cardType forState:UIControlStateNormal];
        [ExtendedInfoView addSubview:CreditCardTypeBtn];
          if (!CreadidCardListTable)
        CreadidCardListTable = [[UITableView alloc] initWithFrame:CGRectMake(ExtendedInfolbl.frame.size.width+5, 280,Efieldwidth-10, 100) style:UITableViewStylePlain];
        CreadidCardListTable.backgroundColor=[UIColor whiteColor];
        CreadidCardListTable.delegate = self;
        CreadidCardListTable.dataSource = self;
        CreadidCardListTable.scrollEnabled = YES;
        CreadidCardListTable.hidden=YES;
        [CreadidCardListTable.layer setBorderWidth: 1.0];
        [CreadidCardListTable.layer setBorderColor:[[UIColor grayColor] CGColor]];
        [ExtendedInfoView addSubview:CreadidCardListTable];
        NSArray *labelArray2;
        if (!labelArray2)
        labelArray2=[[NSArray alloc] initWithObjects:@"DriversLicenseId",@"Exp Date",@"Mobile Phone",@"Fax",nil];
        int b=100;
        
        for (int i=0; i<4; i++)
        {
            
            Extendedblbl2=[[UILabel alloc] init];
            Extendedblbl2.frame=CGRectMake(ExtendedInfolbl.frame.size.width+5+ExtendedField.frame.size.width+5, b,Efieldwidth+10, 40);
            
            Extendedblbl2.tag=i+100;
            [Extendedblbl2 setFont:[UIFont systemFontOfSize:20.0f]];
            [Extendedblbl2 setBackgroundColor:[UIColor clearColor]];
            [Extendedblbl2 setTextColor:[UIColor whiteColor]];
          
            [Extendedblbl2 setText:[labelArray2 objectAtIndex:i]];
            Extendedblbl2.lineBreakMode = NSLineBreakByWordWrapping;
            Extendedblbl2.numberOfLines = 2;
            [Extendedblbl2 setTextAlignment:NSTextAlignmentLeft];
            [ExtendedInfoView addSubview:Extendedblbl2];
            //// //NSLog(@"%f",generalinfolbl.frame.origin.y);
            ExtendedField2=[[UITextField alloc] init];
            //[nameTextfield setBorderStyle:UITextBorderStyleRoundedRect];
            ExtendedField2.frame=CGRectMake(ExtendedInfolbl.frame.size.width+ExtendedField.frame.size.width+Extendedblbl2.frame.size.width-15, b,Efieldwidth-10, 40);
            ExtendedField2.delegate=self;
            ExtendedField2.tag=i+100;
            
            UIView *paddingview=[[UIView alloc] initWithFrame:CGRectMake(5, 0, 5, 20)];
            // // //NSLog(@"%f",GeneralinfoField.frame.origin.y);
            ExtendedField2.leftView = paddingview;
            ExtendedField2.contentVerticalAlignment=UIControlContentVerticalAlignmentCenter;
            ExtendedField2.leftViewMode = UITextFieldViewModeAlways;
            [ExtendedField2 setBackground:[UIImage imageNamed:@"addinputtextfield.png"]];
            if (ExtendedField2.tag==100)
            {
                ExtendedField2.text=EditLicenseId;
                
            }
            if (ExtendedField2.tag==101)
            {
                ExtendedField2.text=EditExpDate;
                
            }
            if (ExtendedField2.tag==102)
            {
                ExtendedField2.text=EditMPhone;
                
            }
            if (ExtendedField2.tag==103)
            {
                ExtendedField2.text=EditFax;
                
            }
            [ExtendedField2 addTarget:self action:@selector(EditExtendedinfoFieldClicked2:) forControlEvents:UIControlEventEditingDidEnd];
            [ExtendedField2 setAutocorrectionType:UITextAutocorrectionTypeNo];
            
            //[dataField addTarget:self action:@selector(adddata:) forControlEvents:UIControlEventTouchUpInside];
            
            [ExtendedInfoView addSubview:ExtendedField2];
            
            b=b+70;
            paddingview=nil;
            
        }
        
        @autoreleasepool {
            SaveExtendedInfoBtn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
            
            SaveExtendedInfoBtn.frame=CGRectMake(Efieldwidth+80, 420, 80, 30);
            [SaveExtendedInfoBtn addTarget:self action:@selector(SaveExtendedData) forControlEvents:UIControlEventTouchUpInside];
            
            //[SaveTaxButton setTitle:@"Save" forState:UIControlStateNormal];
            [SaveExtendedInfoBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
            [SaveExtendedInfoBtn setBackgroundImage:[UIImage imageNamed:@"savegreenbutton.png"] forState:UIControlStateNormal];
            [ExtendedInfoView addSubview:SaveExtendedInfoBtn];
            
            CancelExtendedInfoBtn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
            
            CancelExtendedInfoBtn.frame=CGRectMake(Efieldwidth+230, 420, 80, 30);
            [CancelExtendedInfoBtn addTarget:self action:@selector(CancelExtendedInfo) forControlEvents:UIControlEventTouchUpInside];
            [CancelExtendedInfoBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
            [CancelExtendedInfoBtn setBackgroundImage:[UIImage imageNamed:@"cancelgreenbutton.png"] forState:UIControlStateNormal];
            // [CancelTaxButton setTitle:@"Cancel" forState:UIControlStateNormal];
            [ExtendedInfoView addSubview:CancelExtendedInfoBtn];
        }
    
    }else if (selectedbtn==102){
        if (!ShippingInfoPopUp)
        ShippingInfoPopUp=[[UIView alloc]init];
        if (isLandScope) {
            ShippingInfoPopUp.frame=CGRectMake(0, 0, 1024, 768);
        }else{
            
            ShippingInfoPopUp.frame=CGRectMake(0, 0, 768, 1024);
        }
        [ShippingInfoPopUp setBackgroundColor:[UIColor colorWithRed:10.0f/255.0f green:10.0f/255.0f blue:10.0f/255.0f alpha:0.7f/1.0f]];
        [self.view addSubview:ShippingInfoPopUp];
         if (!ShippingInfoView)
        ShippingInfoView=[[UIScrollView alloc] init];
        if (isLandScope) {
            ShippingInfoView.frame=CGRectMake(50, 100, ShippingInfoPopUp.frame.size.width-100, ShippingInfoPopUp.frame.size.height-250);
            ShippingInfoView.contentSize=CGSizeMake(ShippingInfoPopUp.frame.size.width-100, ShippingInfoPopUp.frame.size.height);
        }else{
            ShippingInfoView.frame=CGRectMake(50, 200, ShippingInfoPopUp.frame.size.width-100, ShippingInfoPopUp.frame.size.height-500);
            ShippingInfoView.contentSize=CGSizeMake(ShippingInfoPopUp.frame.size.width-100, ShippingInfoPopUp.frame.size.height);
        }
        [ShippingInfoView setBackgroundColor:[UIColor colorWithRed:0.0f green:74.0f/255.0f blue:132.0f/255.0f alpha:1.0f]];
        
        [ShippingInfoView.layer setBorderWidth:2.0];
        [ShippingInfoView.layer setBorderColor:[[UIColor whiteColor] CGColor]];
        [ShippingInfoPopUp addSubview:ShippingInfoView];
        
        CGFloat fieldwidth=(ShippingInfoView.frame.size.width)/4;
        
        CGFloat o=(fieldwidth/2);
         if (!ShippingInfoTextlbl)
        ShippingInfoTextlbl=[[UILabel alloc] init];
        ShippingInfoTextlbl.frame=CGRectMake(fieldwidth+60, 10,fieldwidth+100, 40);
        [ShippingInfoTextlbl setFont:[UIFont systemFontOfSize:25.0f]];
        [ShippingInfoTextlbl setBackgroundColor:[UIColor clearColor]];
        [ShippingInfoTextlbl setTextColor:[UIColor whiteColor]];
        [ShippingInfoTextlbl setText:@"Shipping Info Details"];
        [ShippingInfoTextlbl setTextAlignment:NSTextAlignmentLeft];
        [ShippingInfoView addSubview:ShippingInfoTextlbl];
        NSArray *labelArray;
        if (!labelArray)
        labelArray=[[NSArray alloc] initWithObjects:@"First Name",@"Company Name ",@"Street Address",@"City",@"Country",nil];
        int d=60;
        
        for (int i=0; i<5; i++)
        {
            
            ShippingInfolbl=[[UILabel alloc] init];
            ShippingInfolbl.frame=CGRectMake(o-60, d,fieldwidth+10, 40);
            
            ShippingInfolbl.tag=i+100;
            [ShippingInfolbl setFont:[UIFont systemFontOfSize:20.0f]];
            [ShippingInfolbl setBackgroundColor:[UIColor clearColor]];
            [ShippingInfolbl setTextColor:[UIColor whiteColor]];
          
            [ShippingInfolbl setText:[labelArray objectAtIndex:i]];
            [ShippingInfolbl setTextAlignment:NSTextAlignmentLeft];
            [ShippingInfoView addSubview:ShippingInfolbl];
            //// //NSLog(@"%f",generalinfolbl.frame.origin.y);
            ShippingInfoField=[[UITextField alloc] init];
            //[nameTextfield setBorderStyle:UITextBorderStyleRoundedRect];
            ShippingInfoField.frame=CGRectMake(ShippingInfolbl.frame.size.width+5, d,fieldwidth-10, 40);
            ShippingInfoField.delegate=self;
            ShippingInfoField.tag=i+100;
            
            UIView *paddingview=[[UIView alloc] initWithFrame:CGRectMake(5, 0, 5, 20)];
            // // //NSLog(@"%f",GeneralinfoField.frame.origin.y);
            ShippingInfoField.leftView = paddingview;
            ShippingInfoField.contentVerticalAlignment=UIControlContentVerticalAlignmentCenter;
            ShippingInfoField.leftViewMode = UITextFieldViewModeAlways;
            [ShippingInfoField setBackground:[UIImage imageNamed:@"addinputtextfield.png"]];
            if (ShippingInfoField.tag==100)
            {
                ShippingInfoField.text=EditShCompanyName;
            }
            if (ShippingInfoField.tag==101)
            {
                ShippingInfoField.text=EditShStreetAddress;
            }
            if (ShippingInfoField.tag==102)
            {
                ShippingInfoField.text=EditShStreetAddress2;
            }
            if (ShippingInfoField.tag==103)
            {
                ShippingInfoField.text=EditShcity;
            }
            if (ShippingInfoField.tag==104)
            {
                ShippingInfoField.text=EditShCountry;
            }
            [ShippingInfoField addTarget:self action:@selector(EditShippinginfoFieldClicked:) forControlEvents:UIControlEventEditingDidEnd];
            [ShippingInfoField setAutocorrectionType:UITextAutocorrectionTypeNo];
            
            //[dataField addTarget:self action:@selector(adddata:) forControlEvents:UIControlEventTouchUpInside];
            
            [ShippingInfoView addSubview:ShippingInfoField];
            
            d=d+60;
            paddingview=nil;
            
        }
        NSArray *labelArray2;
        if (!labelArray2)
        labelArray2=[[NSArray alloc] initWithObjects:@"Last Name",@"Phone Number",@"ExtendedAddress",@"State",@"Zipcode",nil];
        int b=60;
        
        for (int i=0; i<5; i++)
        {
            
            ShippingInfolbl2=[[UILabel alloc] init];
            ShippingInfolbl2.frame=CGRectMake(ShippingInfolbl.frame.size.width+5+ShippingInfoField.frame.size.width+5, b,fieldwidth+10, 40);
            
            ShippingInfolbl2.tag=i+100;
            [ShippingInfolbl2 setFont:[UIFont systemFontOfSize:20.0f]];
            [ShippingInfolbl2 setBackgroundColor:[UIColor clearColor]];
            [ShippingInfolbl2 setTextColor:[UIColor whiteColor]];
           
            [ShippingInfolbl2 setText:[labelArray2 objectAtIndex:i]];
            [ShippingInfolbl2 setTextAlignment:NSTextAlignmentLeft];
            [ShippingInfoView addSubview:ShippingInfolbl2];
            //// //NSLog(@"%f",generalinfolbl.frame.origin.y);
            ShippingInfoField2=[[UITextField alloc] init];
            //[nameTextfield setBorderStyle:UITextBorderStyleRoundedRect];
            ShippingInfoField2.frame=CGRectMake(ShippingInfolbl.frame.size.width+ShippingInfoField.frame.size.width+ShippingInfolbl2.frame.size.width-5, b,fieldwidth-10, 40);
            ShippingInfoField2.delegate=self;
            ShippingInfoField2.tag=i+100;
            
            UIView *paddingview=[[UIView alloc] initWithFrame:CGRectMake(5, 0, 5, 20)];
            // // //NSLog(@"%f",GeneralinfoField.frame.origin.y);
            ShippingInfoField2.leftView = paddingview;
            ShippingInfoField2.contentVerticalAlignment=UIControlContentVerticalAlignmentCenter;
            ShippingInfoField2.leftViewMode = UITextFieldViewModeAlways;
            [ShippingInfoField2 setBackground:[UIImage imageNamed:@"addinputtextfield.png"]];
            if (ShippingInfoField2.tag==100)
            {
                ShippingInfoField2.text=EditShphone;
            }
            if (ShippingInfoField2.tag==101)
            {
                ShippingInfoField2.text=EditShAlternatePhone;
            }
            if (ShippingInfoField2.tag==102)
            {
                ShippingInfoField2.text=EditShBirthDay;
            }
            if (ShippingInfoField2.tag==103)
            {
                ShippingInfoField2.text=EditShstate;
            }
            if (ShippingInfoField2.tag==104)
            {
                ShippingInfoField2.text=EditShpostalCode;
            }
            [ShippingInfoField2 addTarget:self action:@selector(EditShippinginfoFieldClicked2:) forControlEvents:UIControlEventEditingDidEnd];
            [ShippingInfoField2 setAutocorrectionType:UITextAutocorrectionTypeNo];
            
            //[dataField addTarget:self action:@selector(adddata:) forControlEvents:UIControlEventTouchUpInside];
            
            [ShippingInfoView addSubview:ShippingInfoField2];
            
            b=b+60;
            paddingview=nil;
            
        }
        
        @autoreleasepool {
            SaveShippingInfoBtn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
            
            SaveShippingInfoBtn.frame=CGRectMake(fieldwidth+80, 400, 80, 30);
            [SaveShippingInfoBtn addTarget:self action:@selector(SaveShippingData) forControlEvents:UIControlEventTouchUpInside];
            
            //[SaveTaxButton setTitle:@"Save" forState:UIControlStateNormal];
            [SaveShippingInfoBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
            [SaveShippingInfoBtn setBackgroundImage:[UIImage imageNamed:@"savegreenbutton.png"] forState:UIControlStateNormal];
            [ShippingInfoView addSubview:SaveShippingInfoBtn];
            
            CancelShippingInfoBtn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
            
            CancelShippingInfoBtn.frame=CGRectMake(fieldwidth+220, 400, 80, 30);
            [CancelShippingInfoBtn addTarget:self action:@selector(CancelShippingInfo) forControlEvents:UIControlEventTouchUpInside];
            [CancelShippingInfoBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
            [CancelShippingInfoBtn setBackgroundImage:[UIImage imageNamed:@"cancelgreenbutton.png"] forState:UIControlStateNormal];
            // [CancelTaxButton setTitle:@"Cancel" forState:UIControlStateNormal];
            [ShippingInfoView addSubview:CancelShippingInfoBtn];
        }
      
    }else if (selectedbtn==104){
        if (!NotesBackView)
        NotesBackView=[[UIView alloc]init];
        if (isLandScope) {
            NotesBackView.frame=CGRectMake(0, 0, 1024, 768);
        }else{
            
            NotesBackView.frame=CGRectMake(0, 0, 768, 1024);
        }
        [NotesBackView setBackgroundColor:[UIColor colorWithRed:10.0f/255.0f green:10.0f/255.0f blue:10.0f/255.0f alpha:0.7f/1.0f]];
        [self.view addSubview:NotesBackView];
         if (!NotesView)
        NotesView=[[UIView alloc] init];
        if (isLandScope){
            
            NotesView.frame=CGRectMake(50, 50, NotesBackView.frame.size.width-100, NotesBackView.frame.size.height-150);
        }else{
            NotesView.frame=CGRectMake(50, 150, NotesBackView.frame.size.width-100, NotesBackView.frame.size.height-400);
        }
        
        [NotesView setBackgroundColor:[UIColor colorWithRed:0.0f green:74.0f/255.0f blue:132.0f/255.0f alpha:1.0f]];
        [NotesView.layer setBorderWidth:2.0];
        [NotesView.layer setBorderColor:[[UIColor whiteColor] CGColor]];
        [NotesBackView addSubview:NotesView];
        
        CGFloat widthfield3=(NotesView.frame.size.width)/4;
         if (!Notestextlbl)
        Notestextlbl=[[UILabel alloc] init];
        Notestextlbl.frame=CGRectMake(widthfield3+100,10,widthfield3,40);
        [Notestextlbl setFont:[UIFont systemFontOfSize:25.0f]];
        [Notestextlbl setBackgroundColor:[UIColor clearColor]];
        [Notestextlbl setTextColor:[UIColor whiteColor]];
        [Notestextlbl setText:@"Notes Details"];
        [Notestextlbl setTextAlignment:NSTextAlignmentLeft];
        [NotesView addSubview:Notestextlbl];
        if (!EnterNoteslbl)
        EnterNoteslbl=[[UILabel alloc] init];
        EnterNoteslbl.frame=CGRectMake(widthfield3-60,60,widthfield3,40);
        [EnterNoteslbl setFont:[UIFont systemFontOfSize:20.0f]];
        [EnterNoteslbl setBackgroundColor:[UIColor clearColor]];
        [EnterNoteslbl setTextColor:[UIColor whiteColor]];
        [EnterNoteslbl setText:@"Enter Notes"];
        
        [EnterNoteslbl setTextAlignment:NSTextAlignmentLeft];
        [NotesView addSubview:EnterNoteslbl];
        
        if (!NotesTextView)
        NotesTextView=[[UITextView alloc] init];
        NotesTextView.frame=CGRectMake(10, 115,NotesView.frame.size.width-20,400);
        NotesTextView.delegate=self;
        NotesTextView.text=EditcustomerNotes;
        NotesTextView.font=[UIFont systemFontOfSize:14.0f];
        [NotesTextView setAutocorrectionType:UITextAutocorrectionTypeNo];
        NotesTextView.layer.cornerRadius=8;
        [NotesView addSubview:NotesTextView];
        @autoreleasepool {
            SaveNotesBtn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
            
            SaveNotesBtn.frame=CGRectMake(widthfield3+80,540,80,30);
            [SaveNotesBtn addTarget:self action:@selector(EditSaveCustomerNotes) forControlEvents:UIControlEventTouchUpInside];
            
            //[SaveTaxButton setTitle:@"Save" forState:UIControlStateNormal];
            [SaveNotesBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
            [SaveNotesBtn setBackgroundImage:[UIImage imageNamed:@"savegreenbutton.png"] forState:UIControlStateNormal];
            [NotesView addSubview:SaveNotesBtn];
            
            CancelNotesBtn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
            
            CancelNotesBtn.frame=CGRectMake(widthfield3+230,540,80,30);
            [CancelNotesBtn addTarget:self action:@selector(NotesCancelclicked) forControlEvents:UIControlEventTouchUpInside];
            [CancelNotesBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
            [CancelNotesBtn setBackgroundImage:[UIImage imageNamed:@"cancelgreenbutton.png"] forState:UIControlStateNormal];
            // [CancelTaxButton setTitle:@"Cancel" forState:UIControlStateNormal];
            [NotesView addSubview:CancelNotesBtn];

        }
    }else if (selectedbtn==105){
        SelectedStoredataArray=StoredataFromdatabaseArray;
        if (!StoresPopupView)
        StoresPopupView=[[UIView alloc]init];
        if (isLandScope) {
            StoresPopupView.frame=CGRectMake(0, 0, 1024, 768);
        }else{
        
            StoresPopupView.frame=CGRectMake(0, 0, 768, 1024);
        }
        [StoresPopupView setBackgroundColor:[UIColor colorWithRed:10.0f/255.0f green:10.0f/255.0f blue:10.0f/255.0f alpha:0.7f/1.0f]];
        [self.view addSubview:StoresPopupView];
         if (!StoresView)
        StoresView=[[UIView alloc] init];
        if (isLandScope) {
            StoresView.frame=CGRectMake(50, 50, StoresPopupView.frame.size.width-100, StoresPopupView.frame.size.height-150);
        }else{
            StoresView.frame=CGRectMake(50, 150, StoresPopupView.frame.size.width-100, StoresPopupView.frame.size.height-400);
        }
        [StoresView setBackgroundColor:[UIColor colorWithRed:0.0f green:74.0f/255.0f blue:132.0f/255.0f alpha:1.0f]];
        [StoresView.layer setBorderWidth:2.0];
        [StoresView.layer setBorderColor:[[UIColor whiteColor] CGColor]];
        [StoresPopupView addSubview:StoresView];
        if (!StoreDataArray)
        StoreDataArray=[[NSMutableArray alloc]init];
        NSString *querySQL5 = [NSString stringWithFormat: @"SELECT store_id FROM store_details"];
        NSMutableArray *storesArray=[[NSMutableArray alloc]init];
        [[DataBaseManager dataBaseManager]execute:querySQL5 resultsArray:storesArray];
        for (NSDictionary *myDict in storesArray)
        {
            [StoreDataArray addObject:[myDict objectForKey:@"store_id"]];
        }
        CGFloat widthfield4=(StoresView.frame.size.width)/4;
         if (!StoresTextlbl)
        StoresTextlbl=[[UILabel alloc] init];
        StoresTextlbl.frame=CGRectMake(widthfield4+100,10,widthfield4,40);
        [StoresTextlbl setFont:[UIFont systemFontOfSize:25.0f]];
        [StoresTextlbl setBackgroundColor:[UIColor clearColor]];
        [StoresTextlbl setTextColor:[UIColor whiteColor]];
        [StoresTextlbl setText:@"Store Details"];
        [StoresTextlbl setTextAlignment:NSTextAlignmentLeft];
        [StoresView addSubview:StoresTextlbl];
        
        if (!Storeslbl)
        Storeslbl=[[UILabel alloc] init];
        Storeslbl.frame=CGRectMake(20, 155,widthfield4+10, 40);
        [Storeslbl setFont:[UIFont systemFontOfSize:20.0f]];
        [Storeslbl setBackgroundColor:[UIColor clearColor]];
        [Storeslbl setTextColor:[UIColor whiteColor]];
        [Storeslbl setText:@"Add Store"];
        Storeslbl.lineBreakMode = NSLineBreakByWordWrapping;
        Storeslbl.numberOfLines = 2;
        [Storeslbl setTextAlignment:NSTextAlignmentLeft];
        [StoresView addSubview:Storeslbl];
         if (!StoresBtn)
        StoresBtn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
        StoresBtn.frame=CGRectMake(Storeslbl.frame.size.width-40, 150,widthfield4+10, 40);
        [StoresBtn addTarget:self action:@selector(AddstoreClicked) forControlEvents:UIControlEventTouchUpInside];
        [StoresBtn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
        [StoresBtn setBackgroundImage:[UIImage imageNamed:@"drop-down-icon.png"] forState:UIControlStateNormal];
        // [CancelTaxButton setTitle:@"Cancel" forState:UIControlStateNormal];
        [StoresView addSubview:StoresBtn];
        
        if (!StoresListTable)
        StoresListTable = [[UITableView alloc] initWithFrame:CGRectMake(Storeslbl.frame.size.width-40, 50,widthfield4+10, 100) style:UITableViewStylePlain];
        StoresListTable.backgroundColor=[UIColor whiteColor];
        StoresListTable.delegate = self;
        StoresListTable.dataSource = self;
        StoresListTable.scrollEnabled = YES;
        StoresListTable.hidden=YES;
        [StoresListTable.layer setBorderWidth: 1.0];
        [StoresListTable.layer setBorderColor:[[UIColor grayColor] CGColor]];
        [StoresView addSubview:StoresListTable];
        if (!StoresDataTable)
        StoresDataTable = [[UITableView alloc] initWithFrame:CGRectMake(50, 200,StoresView.frame.size.width-100, 300) style:UITableViewStylePlain];
        StoresDataTable.backgroundColor=[UIColor whiteColor];
        StoresDataTable.delegate = self;
        StoresDataTable.dataSource = self;
        StoresDataTable.scrollEnabled = YES;
        [StoresDataTable.layer setBorderWidth: 1.0];
        [StoresDataTable.layer setBorderColor:[[UIColor grayColor] CGColor]];
        [StoresView addSubview:StoresDataTable];
        @autoreleasepool {
            SavestoresBtn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
            
            SavestoresBtn.frame=CGRectMake(widthfield4+100,540,80,30);
            [SavestoresBtn addTarget:self action:@selector(SaveStores) forControlEvents:UIControlEventTouchUpInside];
            
            //[SaveTaxButton setTitle:@"Save" forState:UIControlStateNormal];
            [SavestoresBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
            [SavestoresBtn setBackgroundImage:[UIImage imageNamed:@"savegreenbutton.png"] forState:UIControlStateNormal];
            [StoresView addSubview:SavestoresBtn];
            
            CancelStoresBtn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
            
            CancelStoresBtn.frame=CGRectMake(widthfield4+230,540,80,30);
            [CancelStoresBtn addTarget:self action:@selector(CancelStores) forControlEvents:UIControlEventTouchUpInside];
            [CancelStoresBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
            [CancelStoresBtn setBackgroundImage:[UIImage imageNamed:@"cancelgreenbutton.png"] forState:UIControlStateNormal];
            // [CancelTaxButton setTitle:@"Cancel" forState:UIControlStateNormal];
            [StoresView addSubview:CancelStoresBtn];
        }
  }else if (selectedbtn==103){
      if (!HistoryPopupView)
        HistoryPopupView=[[UIView alloc]init];
        if (isLandScope) {
            HistoryPopupView.frame=CGRectMake(0, 0, 1024, 768);
        }else{
            
            HistoryPopupView.frame=CGRectMake(0, 0, 768, 1024);
        }
        [HistoryPopupView setBackgroundColor:[UIColor colorWithRed:10.0f/255.0f green:10.0f/255.0f blue:10.0f/255.0f alpha:0.7f/1.0f]];
        [self.view addSubview:HistoryPopupView];
         if (!HistoryView)
        HistoryView=[[UIView alloc] init];
        if (isLandScope){
            HistoryView.frame=CGRectMake(50, 100, HistoryPopupView.frame.size.width-100, HistoryPopupView.frame.size.height-200);
        }else
        {
            HistoryView.frame=CGRectMake(50, 150, HistoryPopupView.frame.size.width-100, HistoryPopupView.frame.size.height-400);
        }
        [HistoryView setBackgroundColor:[UIColor colorWithRed:0.0f green:74.0f/255.0f blue:132.0f/255.0f alpha:1.0f]];
        [HistoryView.layer setBorderWidth:2.0];
        [HistoryView.layer setBorderColor:[[UIColor whiteColor] CGColor]];
        [HistoryPopupView addSubview:HistoryView];
        CGFloat widthfield5=(HistoryView.frame.size.width)/4;
       if (!Historytextlbl)
        Historytextlbl=[[UILabel alloc] init];
        Historytextlbl.frame=CGRectMake(widthfield5+120,10,widthfield5,40);
        [Historytextlbl setFont:[UIFont systemFontOfSize:25.0f]];
        [Historytextlbl setBackgroundColor:[UIColor clearColor]];
        [Historytextlbl setTextColor:[UIColor whiteColor]];
        [Historytextlbl setText:@"History Details"];
        [Historytextlbl setTextAlignment:NSTextAlignmentLeft];
        [HistoryView addSubview:Historytextlbl];
         if (!SalesHistoryTable)
        SalesHistoryTable = [[UITableView alloc] initWithFrame:CGRectMake(10,60,HistoryView.frame.size.width-20, 400) style:UITableViewStylePlain];
        SalesHistoryTable.backgroundColor=[UIColor clearColor];
        SalesHistoryTable.delegate = self;
        SalesHistoryTable.dataSource = self;
        SalesHistoryTable.scrollEnabled = YES;
        [SalesHistoryTable.layer setBorderWidth: 1.0];
        [SalesHistoryTable.layer setBorderColor:[[UIColor grayColor] CGColor]];
        [HistoryView addSubview:SalesHistoryTable];
        if (!saveHistoryBtn)
        saveHistoryBtn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
        saveHistoryBtn.frame=CGRectMake(widthfield5+160,500,80,30);
        [saveHistoryBtn addTarget:self action:@selector(Savehistory) forControlEvents:UIControlEventTouchUpInside];
        
        //[SaveTaxButton setTitle:@"Save" forState:UIControlStateNormal];
        [saveHistoryBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
        [saveHistoryBtn setBackgroundImage:[UIImage imageNamed:@"savegreenbutton.png"] forState:UIControlStateNormal];
        [HistoryView addSubview:saveHistoryBtn];
      
    }

    
}
-(void)EditGeneralinfoFieldClicked:(UITextField *)sender
{
    NSInteger selected=sender.tag;
    if (selected == 100)
    {
        
        EditGCompanyName=sender.text;
    }
    if (selected == 101)
    {
        EditGStreetAddress=sender.text;
    }
    if (selected == 102)
    {
        EditGStreetAddress2=sender.text;
    }
    if (selected == 103)
    {
        
        EditGcity=sender.text;
    }
    if (selected == 104)
    {
        
        EditGCountry=sender.text;
    }
    
}
-(void)EditGeneralinfoFieldClicked2:(UITextField *)sender
{
    NSInteger selected=sender.tag;
    if (selected == 100)
    {
        
        EditGphone=sender.text;
    }
    if (selected == 101)
    {
        EditGAlternatePhone=sender.text;
    }
    if (selected == 102)
    {
        EditGBirthDay=sender.text;
    }
    if (selected == 103)
    {
        
        EditGstate=sender.text;
    }
    if (selected == 104)
    {
        
        EditGpostalCode=sender.text;
    }
}
-(void)EditExtendedinfoFieldClicked:(UITextField *)sender
{
    NSInteger selected=sender.tag;
    if (selected == 100)
    {
        
        EditCardNo=sender.text;
    }
    if (selected == 101)
    {
        EditExpiration=sender.text;
    }
}
-(void)EditExtendedinfoFieldClicked2:(UITextField *)sender
{
    NSInteger selected=sender.tag;
    if (selected == 100)
    {
        
        EditLicenseId=sender.text;
    }
    if (selected == 101)
    {
        EditExpDate=sender.text;
    }
    if (selected == 102)
    {
        EditMPhone=sender.text;
    }
    if (selected == 103)
    {
        
        EditFax=sender.text;
    }
    
}

-(void)EditShippinginfoFieldClicked:(UITextField *)sender
{
    NSInteger selected=sender.tag;
    if (selected == 100)
    {
        
        EditShCompanyName=sender.text;
    }
    if (selected == 101)
    {
        EditShStreetAddress=sender.text;
    }
    if (selected == 102)
    {
        EditShStreetAddress2=sender.text;
    }
    if (selected == 103)
    {
        
        EditShcity=sender.text;
    }
    if (selected == 104)
    {
        
        EditShCountry=sender.text;
    }
    
}

-(void)EditShippinginfoFieldClicked2:(UITextField *)sender
{
    NSInteger selected=sender.tag;
    if (selected == 100)
    {
        
        EditShphone=sender.text;
    }
    if (selected == 101)
    {
        EditShAlternatePhone=sender.text;
    }
    if (selected == 102)
    {
        EditShBirthDay=sender.text;
    }
    if (selected == 103)
    {
        
        EditShstate=sender.text;
    }
    if (selected == 104)
    {
        
        EditShpostalCode=sender.text;
    }
}
-(void)deleteCustomer:(UIButton *)sender
{
  
    
}
-(void)DeleteStoreData:(UIButton *)sender
{
    NSInteger selected=sender.tag;
    [SelectedStoredataArray removeObjectAtIndex:selected];
    [StoresDataTable reloadData];
}
- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex;
{
    if (alertView==deleteCustomerAlert && buttonIndex==0){
        
        NSString *selectedid=[CustomerNosArray objectAtIndex:SelectedCustomer];
        
     customerNO=selectedid;
     
//customer Data
        
    
        NSString *custquerySQL = [NSString stringWithFormat:@"SELECT unique_id FROM customer_table WHERE customer_no='%@'",selectedid];
        NSMutableArray *customersDataArray=[[NSMutableArray alloc]init];
        [[DataBaseManager dataBaseManager]execute:custquerySQL resultsArray:customersDataArray];
        
        NSMutableArray *customeruniqueidsArray=[[NSMutableArray alloc]init];
        for (NSDictionary *Dict in customersDataArray) {
            
            [customeruniqueidsArray addObject:[Dict objectForKey:@"unique_id"]];
        }
        NSError *err;
        
        NSData *jsonData = [NSJSONSerialization dataWithJSONObject:customeruniqueidsArray options:kNilOptions error:&err];
        
        NSString *str=[[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];
        
        if(![generalDataObject  connectedToInternet]){
            
            NSString *insertSQL =@"insert into pending_queries (query_type,user_id,page_url,parameters,table_name,current_time) values(?,?,?,?,?,?)";
            NSMutableArray *pendingArray=[[NSMutableArray alloc]initWithObjects:@"DELETE",[generalDataObject  userID],@"deleteinfo.php?",str,@"customer_table",[generalDataObject getsystemDatetime], nil];
            [[DataBaseManager dataBaseManager] executeRecordsWithQuery:insertSQL withArguments:pendingArray];
            
        }
        else if([generalDataObject  connectedToInternet]){
            
            if ([[generalDataObject  OriginalbaseURLstr] length]>0)
            {
            
            // //NSLog(@"%@",str);
            NSString *string=[NSString stringWithFormat:@"%@deleteinfo.php?tablename=customer_table&systemtime=%@&userid=%@&sessionid=%@&unique_ids=%@",[generalDataObject  OriginalbaseURLstr],[[generalDataObject getsystemDatetime] stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding],[generalDataObject  userID],[generalDataObject  genRandStringLength:20],[str stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];
            
            // //NSLog(@"%@",str);
            
            NSURL *url=[NSURL URLWithString:string];
            NSMutableURLRequest *request = [[NSMutableURLRequest alloc] initWithURL:url];
            // //NSLog(@"%@",url);
            
            [request setHTTPMethod:@"POST"];
            [request setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
            //[request setValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"Content-Type"];
            
            
            
            CustomerConnection = [NSURLConnection connectionWithRequest:request delegate:self];
            
            [CustomerConnection start];
            }
        }
        
        
//General info Data
        
      
        NSString *genselectquerySQL = [NSString stringWithFormat: @"SELECT unique_id FROM customer_general_info_table WHERE customer_no='%@'",selectedid];
        NSMutableArray *geninfoDataArray=[[NSMutableArray alloc]init];
        
        [[DataBaseManager dataBaseManager]execute:genselectquerySQL resultsArray:geninfoDataArray];
        NSMutableArray *geninfouniqueidsArray=[[NSMutableArray alloc]init];
        for (NSDictionary *Dict in geninfoDataArray) {
            
            [geninfouniqueidsArray addObject:[Dict objectForKey:@"unique_id"]];
        }
        NSError *err2;
        
        NSData *jsonData2 = [NSJSONSerialization dataWithJSONObject:geninfouniqueidsArray options:kNilOptions error:&err2];
        
        NSString *str2=[[NSString alloc] initWithData:jsonData2 encoding:NSUTF8StringEncoding];
        
        if(![generalDataObject  connectedToInternet]){
            
            NSString *insertSQL =@"insert into pending_queries (query_type,user_id,page_url,parameters,table_name,current_time) values(?,?,?,?,?,?)";
            NSMutableArray *pendingArray=[[NSMutableArray alloc]initWithObjects:@"DELETE",[generalDataObject  userID],@"deleteinfo.php?",str2,@"customer_general_info_table",[generalDataObject getsystemDatetime], nil];
            [[DataBaseManager dataBaseManager] executeRecordsWithQuery:insertSQL withArguments:pendingArray];
            
        }
        else if([generalDataObject  connectedToInternet]){
            if ([[generalDataObject  OriginalbaseURLstr] length]>0)
            {
            // //NSLog(@"%@",str2);
            NSString *string=[NSString stringWithFormat:@"%@deleteinfo.php?tablename=customer_general_info_table&systemtime=%@&userid=%@&sessionid=%@&unique_ids=%@",[generalDataObject  OriginalbaseURLstr],[[generalDataObject getsystemDatetime] stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding],[generalDataObject  userID],[generalDataObject  genRandStringLength:20],[str2 stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];
            
            
            
            NSURL *url=[NSURL URLWithString:string];
            NSMutableURLRequest *request = [[NSMutableURLRequest alloc] initWithURL:url];
            // //NSLog(@"%@",url);
            
            [request setHTTPMethod:@"POST"];
            [request setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
            //[request setValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"Content-Type"];
            
            
            
            GeneralInfoConnection = [NSURLConnection connectionWithRequest:request delegate:self];
            
            [GeneralInfoConnection start];
            }
        }
        
//Extended info Data
        
        NSString *exdselectquerySQL = [NSString stringWithFormat: @"SELECT unique_id FROM customer_extended_info_table WHERE customer_no='%@'",selectedid];
        NSMutableArray *exdinfoDataArray=[[NSMutableArray alloc]init];
        [[DataBaseManager dataBaseManager]execute:exdselectquerySQL resultsArray:exdinfoDataArray];
        
        NSMutableArray *exduniqueidsArray=[[NSMutableArray alloc]init];
        for (NSDictionary *Dict in exdinfoDataArray) {
            
            [exduniqueidsArray addObject:[Dict objectForKey:@"unique_id"]];
        }
        NSError *err3;
        
        NSData *jsonData3 = [NSJSONSerialization dataWithJSONObject:exduniqueidsArray options:kNilOptions error:&err3];
        
        NSString *str3=[[NSString alloc] initWithData:jsonData3 encoding:NSUTF8StringEncoding];
        
        if(![generalDataObject  connectedToInternet]){
            
            NSString *insertSQL =@"insert into pending_queries (query_type,user_id,page_url,parameters,table_name,current_time) values(?,?,?,?,?,?)";
            NSMutableArray *pendingArray=[[NSMutableArray alloc]initWithObjects:@"DELETE",[generalDataObject  userID],@"deleteinfo.php?",str3,@"customer_extended_info_table",[generalDataObject getsystemDatetime], nil];
            [[DataBaseManager dataBaseManager] executeRecordsWithQuery:insertSQL withArguments:pendingArray];
            
        }
        else if([generalDataObject  connectedToInternet]){
            
            if ([[generalDataObject  OriginalbaseURLstr] length]>0)
            {
            
            // //NSLog(@"%@",str3);
            NSString *string=[NSString stringWithFormat:@"%@deleteinfo.php?tablename=customer_extended_info_table&systemtime=%@&userid=%@&sessionid=%@&unique_ids=%@",[generalDataObject  OriginalbaseURLstr],[[generalDataObject getsystemDatetime] stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding],[generalDataObject  userID],[generalDataObject  genRandStringLength:20],[str3 stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];
            
            
            
            NSURL *url=[NSURL URLWithString:string];
            NSMutableURLRequest *request = [[NSMutableURLRequest alloc] initWithURL:url];
            // //NSLog(@"%@",url);
            
            [request setHTTPMethod:@"POST"];
            [request setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
            //[request setValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"Content-Type"];
            
            
            
            ExtendedConnection = [NSURLConnection connectionWithRequest:request delegate:self];
            
            [ExtendedConnection start];
            }
        }
        
//Shipping Info Data
        
        
        NSString *shpselectquerySQL = [NSString stringWithFormat: @"SELECT unique_id FROM customer_shipping_table WHERE customer_no='%@'",selectedid];
        NSMutableArray *shipingDataArray=[[NSMutableArray alloc]init];
        [[DataBaseManager dataBaseManager]execute:shpselectquerySQL resultsArray:shipingDataArray];
        
        NSMutableArray *shippinguniqueidsArray=[[NSMutableArray alloc]init];
        
        for (NSDictionary *Dict in shipingDataArray) {
            
            [shippinguniqueidsArray addObject:[Dict objectForKey:@"unique_id"]];
        }
        NSError *err4;
        
        NSData *jsonData4 = [NSJSONSerialization dataWithJSONObject:shippinguniqueidsArray options:kNilOptions error:&err4];
        
        NSString *str4=[[NSString alloc] initWithData:jsonData4 encoding:NSUTF8StringEncoding];
        
        if(![generalDataObject  connectedToInternet]){
            
            NSString *insertSQL =@"insert into pending_queries (query_type,user_id,page_url,parameters,table_name,current_time) values(?,?,?,?,?,?)";
            NSMutableArray *pendingArray=[[NSMutableArray alloc]initWithObjects:@"DELETE",[generalDataObject  userID],@"deleteinfo.php?",str4,@"customer_shipping_table",[generalDataObject getsystemDatetime], nil];
            [[DataBaseManager dataBaseManager] executeRecordsWithQuery:insertSQL withArguments:pendingArray];
            
        }
        else if([generalDataObject  connectedToInternet]){
            
            if ([[generalDataObject  OriginalbaseURLstr] length]>0)
            {
            // //NSLog(@"%@",str4);
            NSString *string=[NSString stringWithFormat:@"%@deleteinfo.php?tablename=customer_shipping_table&systemtime=%@&userid=%@&sessionid=%@&unique_ids=%@",[generalDataObject  OriginalbaseURLstr],[[generalDataObject getsystemDatetime] stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding],[generalDataObject  userID],[generalDataObject  genRandStringLength:20],[str4 stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];
            
            
            
            NSURL *url=[NSURL URLWithString:string];
            NSMutableURLRequest *request = [[NSMutableURLRequest alloc] initWithURL:url];
            // //NSLog(@"%@",url);
            
            [request setHTTPMethod:@"POST"];
            [request setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
            //[request setValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"Content-Type"];
            
            
            
            ShippingConnection = [NSURLConnection connectionWithRequest:request delegate:self];
            
            [ShippingConnection start];
            }
        }
        
//Store Data
        
        NSString *storeselectquerySQL = [NSString stringWithFormat: @"SELECT unique_id FROM customer_stores_table WHERE customer_no='%@'",selectedid];
        NSMutableArray *storeDataArray=[[NSMutableArray alloc]init];
        [[DataBaseManager dataBaseManager]execute:storeselectquerySQL resultsArray:storeDataArray];
        NSMutableArray *storeuniqueidsArray=[[NSMutableArray alloc]init];
        
        for (NSDictionary *Dict in storeDataArray) {
            
            [storeuniqueidsArray addObject:[Dict objectForKey:@"unique_id"]];
        }
        NSError *err6;
        
        NSData *jsonData6 = [NSJSONSerialization dataWithJSONObject:storeuniqueidsArray options:kNilOptions error:&err6];
        
        NSString *str6=[[NSString alloc] initWithData:jsonData6 encoding:NSUTF8StringEncoding];
        
        if(![generalDataObject  connectedToInternet]){
            
            NSString *insertSQL =@"insert into pending_queries (query_type,user_id,page_url,parameters,table_name,current_time) values(?,?,?,?,?,?)";
            NSMutableArray *pendingArray=[[NSMutableArray alloc]initWithObjects:@"DELETE",[generalDataObject  userID],@"deleteinfo.php?",str6,@"customer_stores_table",[generalDataObject getsystemDatetime], nil];
            [[DataBaseManager dataBaseManager] executeRecordsWithQuery:insertSQL withArguments:pendingArray];
            
        }
        else if([generalDataObject  connectedToInternet]){
            if ([[generalDataObject  OriginalbaseURLstr] length]>0)
            {
            
            
            // //NSLog(@"%@",str6);
            NSString *string=[NSString stringWithFormat:@"%@deleteinfo.php?tablename=customer_stores_table&systemtime=%@&userid=%@&sessionid=%@&unique_ids=%@",[generalDataObject  OriginalbaseURLstr],[[generalDataObject getsystemDatetime] stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding],[generalDataObject  userID],[generalDataObject  genRandStringLength:20],[str6 stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];
            
            
            
            NSURL *url=[NSURL URLWithString:string];
            NSMutableURLRequest *request = [[NSMutableURLRequest alloc] initWithURL:url];
            // //NSLog(@"%@",url);
            
            [request setHTTPMethod:@"POST"];
            [request setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
            //[request setValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"Content-Type"];
            
            
            
            StoreConnection = [NSURLConnection connectionWithRequest:request delegate:self];
            
            [StoreConnection start];
            }
        }
        
        NSMutableArray *deleteArray=[[NSMutableArray alloc]initWithObjects:selectedid, nil];
        NSString *updateSQL =@"DELETE FROM customer_table WHERE customer_no=?";
        [[DataBaseManager dataBaseManager]executeRecordsWithQuery:updateSQL withArguments:deleteArray];
		      
        NSString *updateSQL2 =@"DELETE FROM customer_shipping_table WHERE customer_no=?";
		 [[DataBaseManager dataBaseManager]executeRecordsWithQuery:updateSQL2 withArguments:deleteArray];
		
        NSString *updateSQL3 =@"DELETE FROM customer_stores_table WHERE customer_no=?";
         [[DataBaseManager dataBaseManager]executeRecordsWithQuery:updateSQL3 withArguments:deleteArray];
		      
        NSString *updateSQL4 =@"DELETE FROM customer_general_info_table WHERE customer_no=?";
         [[DataBaseManager dataBaseManager]executeRecordsWithQuery:updateSQL4 withArguments:deleteArray];
	
        
        NSString *updateSQL5 =@"DELETE FROM customer_extended_info_table WHERE customer_no=?";
         [[DataBaseManager dataBaseManager]executeRecordsWithQuery:updateSQL5 withArguments:deleteArray];
        
        
        NSString *querySQL = [NSString stringWithFormat: @"SELECT customer_no,customer_first_name,customer_last_name,customer_email,customer_notes FROM customer_table"];
        NSMutableArray *customersArray=[[NSMutableArray alloc]init];
        [[DataBaseManager dataBaseManager]execute:querySQL resultsArray:customersArray];
        
        NSMutableArray *rdarray=customersArray;
        
        [customerPaginationObject  setCompleteresultset:rdarray];
        
        [customerPaginationObject   paginationinitializer:rdarray :20];
        
        [customerPaginationObject  paginationsegment].tintColor=[UIColor whiteColor];
        [[customerPaginationObject  paginationsegment] setFrame:CGRectMake(10, AddCustomerBtn.frame.size.height+10,CustomersBackView.frame.size.width-20, 40)];
        
        [[customerPaginationObject  paginationsegment] addTarget:self action:@selector(segmentchanged4:) forControlEvents:UIControlEventValueChanged];
        
        NSInteger selectedsegindex;
        selectedsegindex=0;
        [customerPaginationObject  paginationsegment].selectedSegmentIndex=selectedsegindex;
      [customerPaginationObject  activateResults:selectedsegindex];
    
        [CustomersBackView addSubview:[customerPaginationObject  paginationsegment]];
          [self GetCustomerDataMethod];
        [EditCustomerTable reloadData];
        
    }

}
- (void)connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse *)response
{
    if (connection == CustomerConnection){
        CustomerResponseData = [[NSMutableData alloc] init];
    }else if (connection == GeneralInfoConnection){
        GeneralResponseData = [[NSMutableData alloc] init];
    }else if (connection == ExtendedConnection){
        ExtendedResponseData = [[NSMutableData alloc] init];
    }else if (connection == ShippingConnection){
        ShippingResponseData = [[NSMutableData alloc] init];
    }else if (connection == StoreConnection){
        StoreResponseData = [[NSMutableData alloc] init];
    }
    
}
- (void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data
{
    
    if (connection == CustomerConnection){
        [CustomerResponseData appendData:data];
    }else if (connection == GeneralInfoConnection){
        [GeneralResponseData appendData:data];
    }else if (connection == ExtendedConnection){
        [ExtendedResponseData appendData:data];
        
    }else if (connection == ShippingConnection){
        [ShippingResponseData appendData:data];
        
    }else if (connection == StoreConnection){
       [StoreResponseData appendData:data];
    }
    
}
- (void)connectionDidFinishLoading:(NSURLConnection *)connection
{
    if (connection == CustomerConnection){
        
        NSString *responseStr = [[NSString alloc] initWithBytes:[CustomerResponseData mutableBytes] length:[CustomerResponseData length] encoding:NSUTF8StringEncoding];
        
        NSError *error;
       dataDict=[[NSMutableDictionary alloc] init];
        NSData *jsonData = [responseStr dataUsingEncoding:NSUTF8StringEncoding];
        dataDict =[NSJSONSerialization JSONObjectWithData:jsonData options:0 error:&error];
        // //NSLog(@"%@",dataDict);
        
        NSMutableArray *deleteArray=[dataDict objectForKey:@"delete-queries"];
        NSMutableArray *insertsArray=[dataDict objectForKey:@"insert-queries"];
        
        NSMutableArray *deletesArray;
        for (int i=0; i<[deleteArray count]; i++)
        {
            NSString *foo=[deleteArray objectAtIndex:i];
            NSString* bar = [foo stringByReplacingOccurrencesOfString:@"'" withString:@"\""];
            NSString* deletestr = [bar stringByReplacingOccurrencesOfString:@"\\\"" withString:@"'"];
            [[DataBaseManager dataBaseManager]executeRecordsWithQuery:deletestr withArguments:deletesArray];
            
            NSString *foo2=[insertsArray objectAtIndex:i];
            NSString* bar2 = [foo2 stringByReplacingOccurrencesOfString:@"'" withString:@"\""];
            NSString* insertstr = [bar2 stringByReplacingOccurrencesOfString:@"\\\"" withString:@"'"];
            
            [[DataBaseManager dataBaseManager]executeRecordsWithQuery:insertstr withArguments:deletesArray];
        }
        
      
    }else if (connection == GeneralInfoConnection){
        
        NSString *responseStr = [[NSString alloc] initWithBytes:[GeneralResponseData mutableBytes] length:[GeneralResponseData length] encoding:NSUTF8StringEncoding];
        
        NSError *error;
       dataDict=[[NSMutableDictionary alloc] init];
        NSData *jsonData = [responseStr dataUsingEncoding:NSUTF8StringEncoding];
        dataDict =[NSJSONSerialization JSONObjectWithData:jsonData options:0 error:&error];
        // //NSLog(@"%@",dataDict);
        
        
        NSMutableArray *deleteArray=[dataDict objectForKey:@"delete-queries"];
        NSMutableArray *insertsArray=[dataDict objectForKey:@"insert-queries"];
        
        NSMutableArray *deletesArray;
        for (int i=0; i<[deleteArray count]; i++)
        {
            NSString *foo=[deleteArray objectAtIndex:i];
            NSString* bar = [foo stringByReplacingOccurrencesOfString:@"'" withString:@"\""];
            NSString* deletestr = [bar stringByReplacingOccurrencesOfString:@"\\\"" withString:@"'"];
            [[DataBaseManager dataBaseManager]executeRecordsWithQuery:deletestr withArguments:deletesArray];
            
            NSString *foo2=[insertsArray objectAtIndex:i];
            NSString* bar2 = [foo2 stringByReplacingOccurrencesOfString:@"'" withString:@"\""];
            NSString* insertstr = [bar2 stringByReplacingOccurrencesOfString:@"\\\"" withString:@"'"];
            
            [[DataBaseManager dataBaseManager]executeRecordsWithQuery:insertstr withArguments:deletesArray];
        }
        
       
        
    }else if (connection == ExtendedConnection){
        NSString *responseStr = [[NSString alloc] initWithBytes:[ExtendedResponseData mutableBytes] length:[ExtendedResponseData length] encoding:NSUTF8StringEncoding];
        
        NSError *error;
        dataDict=[[NSMutableDictionary alloc] init];
        NSData *jsonData = [responseStr dataUsingEncoding:NSUTF8StringEncoding];
        dataDict =[NSJSONSerialization JSONObjectWithData:jsonData options:0 error:&error];
        // //NSLog(@"%@",dataDict);
        
        
        NSMutableArray *deleteArray=[dataDict objectForKey:@"delete-queries"];
        NSMutableArray *insertsArray=[dataDict objectForKey:@"insert-queries"];
        NSMutableArray *deletesArray;
        for (int i=0; i<[deleteArray count]; i++)
        {
            NSString *foo=[deleteArray objectAtIndex:i];
            NSString* bar = [foo stringByReplacingOccurrencesOfString:@"'" withString:@"\""];
            NSString* deletestr = [bar stringByReplacingOccurrencesOfString:@"\\\"" withString:@"'"];
            [[DataBaseManager dataBaseManager]executeRecordsWithQuery:deletestr withArguments:deletesArray];
            
            NSString *foo2=[insertsArray objectAtIndex:i];
            NSString* bar2 = [foo2 stringByReplacingOccurrencesOfString:@"'" withString:@"\""];
            NSString* insertstr = [bar2 stringByReplacingOccurrencesOfString:@"\\\"" withString:@"'"];
            
            [[DataBaseManager dataBaseManager]executeRecordsWithQuery:insertstr withArguments:deletesArray];
        }
        
      
    }else if (connection == ShippingConnection){
        NSString *responseStr = [[NSString alloc] initWithBytes:[ShippingResponseData mutableBytes] length:[ShippingResponseData length] encoding:NSUTF8StringEncoding];
        
        NSError *error;
       dataDict=[[NSMutableDictionary alloc] init];
        NSData *jsonData = [responseStr dataUsingEncoding:NSUTF8StringEncoding];
        dataDict =[NSJSONSerialization JSONObjectWithData:jsonData options:0 error:&error];
        // //NSLog(@"%@",dataDict);
        
        
        NSMutableArray *deleteArray=[dataDict objectForKey:@"delete-queries"];
        NSMutableArray *insertsArray=[dataDict objectForKey:@"insert-queries"];
        
        NSMutableArray *deletesArray;
        for (int i=0; i<[deleteArray count]; i++)
        {
            NSString *foo=[deleteArray objectAtIndex:i];
            NSString* bar = [foo stringByReplacingOccurrencesOfString:@"'" withString:@"\""];
            NSString* deletestr = [bar stringByReplacingOccurrencesOfString:@"\\\"" withString:@"'"];
            [[DataBaseManager dataBaseManager]executeRecordsWithQuery:deletestr withArguments:deletesArray];
            
            NSString *foo2=[insertsArray objectAtIndex:i];
            NSString* bar2 = [foo2 stringByReplacingOccurrencesOfString:@"'" withString:@"\""];
            NSString* insertstr = [bar2 stringByReplacingOccurrencesOfString:@"\\\"" withString:@"'"];
            
            [[DataBaseManager dataBaseManager]executeRecordsWithQuery:insertstr withArguments:deletesArray];
        }
        
      
    }else if (connection == StoreConnection){
        NSString *responseStr = [[NSString alloc] initWithBytes:[StoreResponseData mutableBytes] length:[StoreResponseData length] encoding:NSUTF8StringEncoding];
        
        NSError *error;
       dataDict=[[NSMutableDictionary alloc] init];
        NSData *jsonData = [responseStr dataUsingEncoding:NSUTF8StringEncoding];
        dataDict =[NSJSONSerialization JSONObjectWithData:jsonData options:0 error:&error];
        // //NSLog(@"%@",dataDict);
        
        
        NSMutableArray *deleteArray=[dataDict objectForKey:@"delete-queries"];
        NSMutableArray *insertsArray=[dataDict objectForKey:@"insert-queries"];
        
        NSMutableArray *deletesArray;
        for (int i=0; i<[deleteArray count]; i++)
        {
            NSString *foo=[deleteArray objectAtIndex:i];
            NSString* bar = [foo stringByReplacingOccurrencesOfString:@"'" withString:@"\""];
            NSString* deletestr = [bar stringByReplacingOccurrencesOfString:@"\\\"" withString:@"'"];
            [[DataBaseManager dataBaseManager]executeRecordsWithQuery:deletestr withArguments:deletesArray];
            
            NSString *foo2=[insertsArray objectAtIndex:i];
            NSString* bar2 = [foo2 stringByReplacingOccurrencesOfString:@"'" withString:@"\""];
            NSString* insertstr = [bar2 stringByReplacingOccurrencesOfString:@"\\\"" withString:@"'"];
            
            [[DataBaseManager dataBaseManager]executeRecordsWithQuery:insertstr withArguments:deletesArray];
        }
        
    
    }
    dataDict=nil;
}
-(void)removeAllArraysDatamethod
{
    [CustomerNosArray  removeAllObjects], [CuFirstnamesArray  removeAllObjects], [CuLastnamesArray  removeAllObjects], [EmailsArray  removeAllObjects], [CustomerNotesArray  removeAllObjects];
    CustomerNosArray =nil, CuFirstnamesArray =nil, CuLastnamesArray =nil, EmailsArray =nil, CustomerNotesArray =nil;
    [GeneCompanyNamesArray  removeAllObjects], [GeneStreetAddressArray  removeAllObjects], [GeneStaddress2Array  removeAllObjects], [GeneCitysArray  removeAllObjects], [GeneCountrysArray  removeAllObjects], [GeneZipcodesArray  removeAllObjects], [GenephoneArray  removeAllObjects], [GeneAleternatePhonesArray  removeAllObjects], [GeneBirthDaysArray  removeAllObjects], [GeneStatesArray  removeAllObjects];
    GeneCompanyNamesArray =nil, GeneStreetAddressArray =nil, GeneStaddress2Array =nil, GeneCitysArray =nil, GeneCountrysArray =nil, GeneZipcodesArray =nil, GenephoneArray =nil, GeneAleternatePhonesArray =nil, GeneBirthDaysArray =nil, GeneStatesArray =nil;
    [itemIDArray  removeAllObjects], [itemNameArray  removeAllObjects], [discountArray  removeAllObjects], [taxArray  removeAllObjects], [yourCostArray  removeAllObjects], [avgArray  removeAllObjects], [quantityArray  removeAllObjects], [dateArray  removeAllObjects], [SnosArray  removeAllObjects];
    itemIDArray =nil, itemNameArray =nil, discountArray =nil, taxArray =nil, yourCostArray =nil, avgArray =nil, quantityArray =nil, dateArray =nil, SnosArray =nil;
    [StoreDataArray  removeAllObjects], [SelectedStoredataArray  removeAllObjects];
    [StoredataFromdatabaseArray  removeAllObjects];
    
    StoreDataArray =nil, SelectedStoredataArray =nil;
    StoredataFromdatabaseArray =nil;

}

-(void)AddCustomer
{
    [EditCustomerBtn setBackgroundImage:[UIImage imageNamed:@" "] forState:UIControlStateNormal];
    [AddCustomerBtn setBackgroundImage:[UIImage imageNamed:@"bluetabactive.png"] forState:UIControlStateNormal];
    [EditCustomerBtn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    [AddCustomerBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
   // [edittaxTable removeFromSuperview];
   
    [[customerPaginationObject  paginationsegment]  removeFromSuperview];
    [EditCustomerTable removeFromSuperview];
     [CustomersBackView addSubview:AddCustomersView];
    SelectedStoredataArray=[[NSMutableArray alloc]init];
}
-(void)Editcustomer
{
    [AddCustomerBtn setBackgroundColor:[UIColor whiteColor]];
    [AddCustomerBtn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    [EditCustomerBtn setBackgroundImage:[UIImage imageNamed:@"bluetabactive.png"] forState:UIControlStateNormal];
    //addtaxBtn.backgroundColor=[UIColor colorWithRed:203.0f green:203.0f/255.0f blue:203.0f/255.0f alpha:1.0f];
    [AddCustomerBtn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    [EditCustomerBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    [AddCustomerBtn setBackgroundImage:[UIImage imageNamed:@" "] forState:UIControlStateNormal];
    [AddCustomersView removeFromSuperview];
   
    
    NSString *querySQL = [NSString stringWithFormat: @"SELECT customer_no,customer_first_name,customer_last_name,customer_email,customer_notes FROM customer_table"];
    NSMutableArray *customersArray=[[NSMutableArray alloc]init];
    [[DataBaseManager dataBaseManager]execute:querySQL resultsArray:customersArray];
    
    NSMutableArray *rdarray=customersArray;
    
    [customerPaginationObject  setCompleteresultset:rdarray];
    
    [customerPaginationObject   paginationinitializer:rdarray :20];
    
    [customerPaginationObject  paginationsegment].tintColor=[UIColor whiteColor];
    [[customerPaginationObject  paginationsegment] setFrame:CGRectMake(10, AddCustomerBtn.frame.size.height+10,CustomersBackView.frame.size.width-20, 40)];
    
    [[customerPaginationObject  paginationsegment] addTarget:self action:@selector(segmentchanged4:) forControlEvents:UIControlEventValueChanged];
    
    NSInteger selectedsegindex;
    selectedsegindex=0;
    [customerPaginationObject  paginationsegment].selectedSegmentIndex=selectedsegindex;
    [customerPaginationObject  activateResults:selectedsegindex];
    [CustomersBackView addSubview:[customerPaginationObject  paginationsegment]];
    [self GetCustomerDataMethod];
    [CustomersBackView addSubview:EditCustomerTable];
    
}
-(void) GetCustomerDataMethod
{
    NSString *custquerySQL = [NSString stringWithFormat:@"SELECT customer_no,customer_first_name,customer_last_name,customer_email,customer_notes FROM customer_table"];
    NSMutableArray *customersDataArray=[[NSMutableArray alloc]init];
    [[DataBaseManager dataBaseManager]execute:custquerySQL resultsArray:customersDataArray];
    
    NSString *genselectquerySQL = [NSString stringWithFormat: @"SELECT customer_company_name,customer_primary_phone,customer_alternate_phone,customer_street1,customer_street2,customer_state,customer_city,customer_country,customer_zipcode,customer_birthday,customer_no FROM customer_general_info_table "];
    NSMutableArray *geninfoDataArray=[[NSMutableArray alloc]init];
    
    [[DataBaseManager dataBaseManager]execute:genselectquerySQL resultsArray:geninfoDataArray];
    
    NSString *exdselectquerySQL = [NSString stringWithFormat: @"SELECT credit_card_num,expiration,credit_card_type,driving_license,exp_date,customer_mobile,customer_fax,customer_no FROM customer_extended_info_table "];
    NSMutableArray *exdinfoDataArray=[[NSMutableArray alloc]init];
    [[DataBaseManager dataBaseManager]execute:exdselectquerySQL resultsArray:exdinfoDataArray];

    NSString *shpselectquerySQL = [NSString stringWithFormat: @"SELECT shipping_first_name,shipping_company_name,shipping_street,shipping_city,shipping_country,shipping_last_name,shipping_phone,shipping_extended,shipping_state,shipping_zipcode,customer_no FROM customer_shipping_table "];
    NSMutableArray *shipingDataArray=[[NSMutableArray alloc]init];
    [[DataBaseManager dataBaseManager]execute:shpselectquerySQL resultsArray:shipingDataArray];
    
        CustomerNosArray=[[NSMutableArray alloc]init];
        CuFirstnamesArray=[[NSMutableArray alloc]init];
        CuLastnamesArray=[[NSMutableArray alloc]init];
        EmailsArray=[[NSMutableArray alloc]init];
        CustomerNotesArray=[[NSMutableArray alloc]init];

  
    @autoreleasepool {
        for (NSDictionary *myDict in [customerPaginationObject  activeresultset])
        {
            [CustomerNosArray addObject:[myDict objectForKey:@"customer_no"]];
            [CuFirstnamesArray addObject:[myDict objectForKey:@"customer_first_name"]];
            [CuLastnamesArray addObject:[myDict objectForKey:@"customer_last_name"]];
            [EmailsArray addObject:[myDict objectForKey:@"customer_email"]];
            [CustomerNotesArray addObject:[myDict objectForKey:@"customer_notes"]];
        }
    }
    
        ShCompanynamesArray=[[NSMutableArray alloc]init];
        ShFirstnamesArray=[[NSMutableArray alloc]init];
        ShlastnamesArray=[[NSMutableArray alloc]init];
        ShStreetsArray=[[NSMutableArray alloc]init];
        ShCitysArray=[[NSMutableArray alloc]init];
        
        ShCountrysArray=[[NSMutableArray alloc]init];
        ShPhonenumbersArray=[[NSMutableArray alloc]init];
        ShExdedArressArray=[[NSMutableArray alloc]init];
        ShSatesArray=[[NSMutableArray alloc]init];
        ShZipcodesArray=[[NSMutableArray alloc]init];
   
   
    @autoreleasepool {
        for (NSDictionary *myDict in shipingDataArray)
        {
            [ShExdedArressArray addObject:[myDict objectForKey:@"shipping_extended"]];
            [ShPhonenumbersArray addObject:[myDict objectForKey:@"shipping_phone"]];
            [ShCompanynamesArray addObject:[myDict objectForKey:@"shipping_company_name"]];
            
            [ShFirstnamesArray addObject:[myDict objectForKey:@"shipping_first_name"]];
            [ShlastnamesArray addObject:[myDict objectForKey:@"shipping_last_name"]];
            [ShStreetsArray addObject:[myDict objectForKey:@"shipping_street"]];
            
            [ShCitysArray addObject:[myDict objectForKey:@"shipping_city"]];
            [ShCountrysArray addObject:[myDict objectForKey:@"shipping_country"]];
            [ShSatesArray addObject:[myDict objectForKey:@"shipping_state"]];
            [ShZipcodesArray addObject:[myDict objectForKey:@"shipping_zipcode"]];
            
        }
    }
    
   
    
        GeneCompanyNamesArray=[[NSMutableArray alloc]init];
        GeneStreetAddressArray=[[NSMutableArray alloc]init];
        GeneStaddress2Array=[[NSMutableArray alloc]init];
        GeneCitysArray=[[NSMutableArray alloc]init];
        GeneCountrysArray=[[NSMutableArray alloc]init];
        
        GeneZipcodesArray=[[NSMutableArray alloc]init];
        GenephoneArray=[[NSMutableArray alloc]init];
        GeneAleternatePhonesArray=[[NSMutableArray alloc]init];
        GeneBirthDaysArray=[[NSMutableArray alloc]init];
        GeneStatesArray=[[NSMutableArray alloc]init];
   
   
    @autoreleasepool {
        for (NSDictionary *myDict in geninfoDataArray)
        {
            [GeneCompanyNamesArray addObject:[myDict objectForKey:@"customer_company_name"]];
            [GeneCountrysArray addObject:[myDict objectForKey:@"customer_country"]];
            [GeneStaddress2Array addObject:[myDict objectForKey:@"customer_street2"]];
            
            [GeneCitysArray addObject:[myDict objectForKey:@"customer_city"]];
            [GeneZipcodesArray addObject:[myDict objectForKey:@"customer_zipcode"]];
            [GenephoneArray addObject:[myDict objectForKey:@"customer_primary_phone"]];
            
            [GeneAleternatePhonesArray addObject:[myDict objectForKey:@"customer_alternate_phone"]];
            [GeneBirthDaysArray addObject:[myDict objectForKey:@"customer_birthday"]];
            [GeneStatesArray addObject:[myDict objectForKey:@"customer_state"]];
            [GeneStreetAddressArray addObject:[myDict objectForKey:@"customer_street1"]];
            
        }

    }
        CardNosArray=[[NSMutableArray alloc]init];
        CardtypesArray=[[NSMutableArray alloc]init];
        ExpirationsArray=[[NSMutableArray alloc]init];
        ExpDatesArray=[[NSMutableArray alloc]init];
        LicensesArray=[[NSMutableArray alloc]init];
        
        MPhonesArray=[[NSMutableArray alloc]init];
        FaxesArray=[[NSMutableArray alloc]init];
   
    @autoreleasepool {
        for (NSDictionary *myDict in exdinfoDataArray)
        {
            [CardNosArray addObject:[myDict objectForKey:@"credit_card_num"]];
            [CardtypesArray addObject:[myDict objectForKey:@"credit_card_type"]];
            [ExpirationsArray addObject:[myDict objectForKey:@"expiration"]];
            
            [LicensesArray addObject:[myDict objectForKey:@"driving_license"]];
            [ExpDatesArray addObject:[myDict objectForKey:@"exp_date"]];
            [MPhonesArray addObject:[myDict objectForKey:@"customer_mobile"]];
            
            [FaxesArray addObject:[myDict objectForKey:@"customer_fax"]];

        }
    }
    //CustomerNosArray objectAtIndex:indexPath.row-1];
   //[CuFirstnamesArray objectAtIndex:indexPath.row-1];
   // cell.lastName_TextView.text =[CuLastnamesArray objectAtIndex:indexPath.row-1];
   // cell.address_TextView.text =[ShExdedArressArray objectAtIndex:indexPath.row-1];
    //cell.company_TextView.text =[ShCompanynamesArray objectAtIndex:indexPath.row-1];
    //cell.phone_TextView.text =[ShPhonenumbersArray

   
}

- (void)longPress:(UILongPressGestureRecognizer*)gesture {
    if ( gesture.state == UIGestureRecognizerStateEnded ) {
        // //NSLog(@"Long Press");
    }
}
- (BOOL)shouldAutorotate
{
    // //NSLog(@"called");
    
    
    return YES;
    
    
}
-(void)updateUI
{
    
    if (isLandScope)
    {
        
        CGFloat width,height;
        
        width=1024;
        height=748;
        backgroundcolorview.frame=CGRectMake(0,y,width,height-100);
        
        
        //  sidemenu.frame=CGRectMake(0, 1,170 ,height-150);
        //sidemenu.hidden=YES;
        
        [categorybutton setFrame:CGRectMake(0.0,p,170,40)];
        navBar.frame=CGRectMake(0, 0,width , 50.0);
        
        [logoBtn setFrame:CGRectMake(60,0,250,50)];
        sationLbl.frame=CGRectMake(navBar.frame.size.width-280, 5,100, 40);
        EmpIdlbl.frame=CGRectMake(navBar.frame.size.width-193, 5,150, 40);
        Timelbl.frame=CGRectMake(navBar.frame.size.width-62, 6,80, 40);
        // mainview.frame=CGRectMake(sidemenu.frame.size.width+10,0,width-(sidemenu.frame.size.width+20),height-150);
        mainview.frame=CGRectMake(20,60,width-40,height-200);
        
        [backgroundcolorview addSubview:mainview];
        [menubutton setFrame:CGRectMake(0,0,50,50)];
        maintoolBar.frame = CGRectMake(0, 0, mainview.frame.size.width, 40);
        
        logoimageview.frame=CGRectMake(50, (backgroundcolorview.frame.size.height)+5+y,(height-(backgroundcolorview.frame.size.height)-30), (height-(backgroundcolorview.frame.size.height)-30));
        
        [helpiconButton setFrame:CGRectMake(width-180,(backgroundcolorview.frame.size.height)+10+y,70,70)];
        
        
        [logouticonButton setFrame:CGRectMake(width-100,(backgroundcolorview.frame.size.height)+10+y,70,70)];
        
        
        //Customers View
        
        
        CustomersBackView.frame=CGRectMake(10, 0, mainview.frame.size.width-20, (mainview.frame.size.height));
       
        
        CGFloat addbuttonwidth=(CustomersBackView.frame.size.width-10)/2;
        AddCustomerBtn.frame=CGRectMake(10, 10, addbuttonwidth, 40);
       
        EditCustomerBtn.frame=CGRectMake(AddCustomerBtn.frame.size.width, 10, addbuttonwidth, 40);
        
        
        AddCustomersView.frame=CGRectMake(10, AddCustomerBtn.frame.size.height+10, CustomersBackView.frame.size.width-20, CustomersBackView.frame.size.height-20-AddCustomerBtn.frame.size.height);
        
        
        CGFloat customerW=(AddCustomersView.frame.size.width)/4;
        CGFloat r=(customerW/2)+20;
        
       
        CustomerLbl.frame=CGRectMake(r-80, 30,customerW, 50);
        
       
        CustomerField.frame=CGRectMake(customerW-5, 35,customerW, 40);
       
        Lastnamelbl.frame=CGRectMake(r-80, 100,customerW, 50);
        
     
        LastnameField.frame=CGRectMake(customerW-5, 105,customerW, 40);
      
        firstnamelbl.frame=CGRectMake(customerW+5+LastnameField.frame.size.width+10, 30,customerW, 50);
        
     
        FirstnameField.frame=CGRectMake(customerW-15+LastnameField.frame.size.width+firstnamelbl.frame.size.width, 35,customerW, 40);
      
        Emaillbl.frame=CGRectMake(customerW+5+LastnameField.frame.size.width+10, 100,customerW, 50);
    
        EmailField.frame=CGRectMake(customerW-15+LastnameField.frame.size.width+firstnamelbl.frame.size.width, 105,customerW, 40);
       
        
        CGFloat wdth=(AddCustomersView.frame.size.width)/7;
        CGFloat xvalue=wdth/4;
        for (int k=0; k<6; k++)
        {
           
            UIButton *mybtn=(UIButton *)[AddCustomersView viewWithTag:k+100];
            mybtn.frame=CGRectMake(xvalue-13,200,wdth+5, 40);
            [AddCustomersView addSubview:mybtn];
            
          xvalue=xvalue+wdth+12;
            
        }
        
        SavecustomerBtn.frame=CGRectMake(customerW+100, 300, 80, 30);
    
        CancelCustomerBtn.frame=CGRectMake(customerW+220, 300, 80, 30);
        
        
        [[customerPaginationObject  paginationsegment] setFrame:CGRectMake(10, AddCustomerBtn.frame.size.height+10,CustomersBackView.frame.size.width-20, 40)];
        
        EditCustomerTable.frame=CGRectMake(10, AddCustomerBtn.frame.size.height+50, CustomersBackView.frame.size.width-20, CustomersBackView.frame.size.height-20-AddCustomerBtn.frame.size.height-40);
        
//General Info View
        
        GeneralInfoPopUp.frame=CGRectMake(0, 0, 1024, 768);
   
        
        GeneralInfoView.frame=CGRectMake(50, 100, GeneralInfoPopUp.frame.size.width-100, GeneralInfoPopUp.frame.size.height-250);
       
          //  GeneralInfoView.frame=CGRectMake(50, 150, GeneralInfoPopUp.frame.size.width-100, GeneralInfoPopUp.frame.size.height-500);
        

    
        GeneralInfoView.contentSize=CGSizeMake(GeneralInfoPopUp.frame.size.width-100, GeneralInfoPopUp.frame.size.height);
    CGFloat fieldwidth=(GeneralInfoView.frame.size.width)/4;
         GeneralInfoTextlbl.frame=CGRectMake(fieldwidth+60, 10,fieldwidth+100, 40);
    CGFloat o=(fieldwidth/2);
    int d=60;
    
    for (int i=0; i<5; i++)
    {
        UILabel *mylabel=(UILabel *)[GeneralInfoView viewWithTag:i+100];
        mylabel.frame=CGRectMake(o-60, d,fieldwidth+10, 40);
        [GeneralInfoView addSubview:mylabel];
        
        UITextField *mytextfield=(UITextField *)[GeneralInfoView viewWithTag:i+100];
        mytextfield.frame=CGRectMake(mylabel.frame.size.width+5, d,fieldwidth-10, 40);
        [GeneralInfoView addSubview:mytextfield];
        
        
        d=d+60;
        
    }
    
    int b=60;
    
    for (int i=0; i<5; i++)
    {
        
        
        UILabel *mylabel=(UILabel *)[GeneralInfoView viewWithTag:i+100];
        mylabel.frame=CGRectMake(GeneralInfolbl.frame.size.width+5+GeneralInfoField.frame.size.width+5, b,fieldwidth+10, 40);
        [GeneralInfoView addSubview:mylabel];
        
        UITextField *mytextfield=(UITextField *)[GeneralInfoView viewWithTag:i+100];
        mytextfield.frame=CGRectMake(GeneralInfolbl.frame.size.width+GeneralInfoField.frame.size.width+mylabel.frame.size.width-5, b,fieldwidth-10, 40);
        [GeneralInfoView addSubview:mytextfield];
        
        b=b+60;
        
    }
        
    SaveGeneralInfoBtn.frame=CGRectMake(fieldwidth+80, 400, 80, 30);
    CancelGeneralInfoBtn.frame=CGRectMake(fieldwidth+240, 400, 80, 30);
//Extended View
        
        ExtendedInfopopUp.frame=CGRectMake(0, 0, 1024, 768);
 
        
        ExtendedInfoView.frame=CGRectMake(50, 100, ExtendedInfopopUp.frame.size.width-100, ExtendedInfopopUp.frame.size.height-250);
        
           // ExtendedInfoView.frame=CGRectMake(50, 150, ExtendedInfopopUp.frame.size.width-100, ExtendedInfopopUp.frame.size.height-500);
        
        
    ExtendedInfoView.contentSize=CGSizeMake(ExtendedInfopopUp.frame.size.width-100, ExtendedInfopopUp.frame.size.height);
    
    
    
    CGFloat Efieldwidth=(ExtendedInfoView.frame.size.width)/4;
    
    CGFloat E=(Efieldwidth/2);
   
    ExdInfotextlbl.frame=CGRectMake(Efieldwidth+60, 10,Efieldwidth+100, 40);
    
    
    CreditcardInfolbl.frame=CGRectMake(Efieldwidth-40, 50,Efieldwidth+50, 40);
    
    PersonalInfolbl.frame=CGRectMake(Efieldwidth+CreditcardInfolbl.frame.size.width+40, 50,Efieldwidth+100, 40);
    
  
    int k=100;
    
    for (int i=0; i<2; i++)
    {
        
       
        UILabel *mylabel=(UILabel *)[ExtendedInfoView viewWithTag:i+100];
        mylabel.frame=CGRectMake(E-70, k,Efieldwidth+10, 40);
        [ExtendedInfoView addSubview:mylabel];
        
        UITextField *mytextfield=(UITextField *)[ExtendedInfoView viewWithTag:i+100];
        mytextfield.frame=CGRectMake(mylabel.frame.size.width+5, k,Efieldwidth-10, 40);
        [ExtendedInfoView addSubview:mytextfield];
        
        k=k+70;
        
    }
        CreditCardtypelbl.frame=CGRectMake(E-70, 240,Efieldwidth+10, 40);

        CreditCardTypeBtn.frame=CGRectMake(ExtendedInfolbl.frame.size.width+5, 240,Efieldwidth-10, 40);
        CreadidCardListTable.frame =CGRectMake(ExtendedInfolbl.frame.size.width+5, 280,Efieldwidth-10, 100);
        

    int s=100;
    
    for (int i=0; i<4; i++)
    {
    
        UILabel *mylabel=(UILabel *)[ExtendedInfoView viewWithTag:i+100];
        mylabel.frame=CGRectMake(ExtendedInfolbl.frame.size.width+5+ExtendedField.frame.size.width+5, s,Efieldwidth+10, 40);
        [ExtendedInfoView addSubview:mylabel];
        
        UITextField *mytextfield=(UITextField *)[ExtendedInfoView viewWithTag:i+100];
        mytextfield.frame=CGRectMake(ExtendedInfolbl.frame.size.width+ExtendedField.frame.size.width+mylabel.frame.size.width-15, s,Efieldwidth-10, 40);
        [ExtendedInfoView addSubview:mytextfield];
        
        s=s+70;
        
    }

    SaveExtendedInfoBtn.frame=CGRectMake(Efieldwidth+80, 420, 80, 30);
    CancelExtendedInfoBtn.frame=CGRectMake(Efieldwidth+230, 420, 80, 30);

    
       
//Notes View
        
    NotesBackView.frame=CGRectMake(0, 0, 1024, 768);
  
        NotesView.frame=CGRectMake(50, 50, NotesBackView.frame.size.width-100, NotesBackView.frame.size.height-150);
   
       // NotesView.frame=CGRectMake(50, 150, NotesBackView.frame.size.width-100, NotesBackView.frame.size.height-400);

    CGFloat widthfield3=(NotesView.frame.size.width)/4;
 
    Notestextlbl.frame=CGRectMake(widthfield3+100,10,widthfield3,40);
   
    EnterNoteslbl.frame=CGRectMake(widthfield3-60,60,widthfield3,40);
 
    NotesTextView.frame=CGRectMake(10, 115,NotesView.frame.size.width-20,400);
   
    
    SaveNotesBtn.frame=CGRectMake(widthfield3+80,540,80,40);

    CancelNotesBtn.frame=CGRectMake(widthfield3+230,540,80,40);
    
//Shpping View
        
        
        ShippingInfoPopUp.frame=CGRectMake(0, 0, 1024, 768);
        ShippingInfoView.frame=CGRectMake(50, 100, ShippingInfoPopUp.frame.size.width-100, ShippingInfoPopUp.frame.size.height-250);
   
      //  ShippingInfoView.frame=CGRectMake(50, 200, ShippingInfoPopUp.frame.size.width-100, ShippingInfoPopUp.frame.size.height-500);
      ShippingInfoView.contentSize=CGSizeMake(ShippingInfoPopUp.frame.size.width-100, ShippingInfoPopUp.frame.size.height);
  
        
        CGFloat fieldwidth2=(ShippingInfoView.frame.size.width)/4;
        
        CGFloat sh=(fieldwidth2/2);
        ShippingInfoTextlbl.frame=CGRectMake(fieldwidth2+60, 10,fieldwidth2+100, 40);
    
    int l=60;
    
    for (int i=0; i<5; i++)
    {
        
     
        UILabel *mylabel=(UILabel *)[ShippingInfoView viewWithTag:i+100];
        mylabel.frame=CGRectMake(sh-60, l,fieldwidth2+10, 40);
        [ShippingInfoView addSubview:mylabel];
        
        UITextField *mytextfield=(UITextField *)[ShippingInfoView viewWithTag:i+100];
        mytextfield.frame=CGRectMake(mylabel.frame.size.width+5, l,fieldwidth2-10, 40);
        [ShippingInfoView addSubview:mytextfield];
        
        
        l=l+60;
        
    }
    
    int m=60;
    
    for (int i=0; i<5; i++)
    {
    
        UILabel *mylabel=(UILabel *)[ShippingInfoView viewWithTag:i+100];
        mylabel.frame=CGRectMake(ShippingInfolbl.frame.size.width+5+ShippingInfoField.frame.size.width+5, m,fieldwidth2+10, 40);
        [ShippingInfoView addSubview:mylabel];
        
        UITextField *mytextfield=(UITextField *)[ShippingInfoView viewWithTag:i+100];
        mytextfield.frame=CGRectMake(ShippingInfolbl.frame.size.width+ShippingInfoField.frame.size.width+mylabel.frame.size.width-5, m,fieldwidth2-10, 40);
        [ShippingInfoView addSubview:mytextfield];
        

        m=m+60;
        
    }

    SaveShippingInfoBtn.frame=CGRectMake(fieldwidth2+80, 400, 80, 30);
    CancelShippingInfoBtn.frame=CGRectMake(fieldwidth2+220, 400, 80, 30);
        
        
  //Stores View
        
        
    StoresPopupView.frame=CGRectMake(0, 0, 1024, 768);
  
        StoresView.frame=CGRectMake(50, 50, StoresPopupView.frame.size.width-100, StoresPopupView.frame.size.height-150);
   
      //  StoresView.frame=CGRectMake(50, 150, StoresPopupView.frame.size.width-100, StoresPopupView.frame.size.height-400);
    
    CGFloat widthfield4=(StoresView.frame.size.width)/4;
    StoresTextlbl.frame=CGRectMake(widthfield4+100,10,widthfield4,40);
   
    Storeslbl.frame=CGRectMake(20, 155,widthfield4+10, 40);

    StoresBtn.frame=CGRectMake(Storeslbl.frame.size.width-40, 150,widthfield4+10, 40);
    StoresListTable .frame= CGRectMake(Storeslbl.frame.size.width-40, 50,widthfield4+10, 100);
    StoresDataTable .frame= CGRectMake(50, 200,StoresView.frame.size.width-100, 300);
    SavestoresBtn.frame=CGRectMake(widthfield4+100,540,80,30);
    CancelStoresBtn.frame=CGRectMake(widthfield4+230,540,80,30);
    
  //Edit customer view
        
        EditCustomersBackView.frame=CGRectMake(0, 0, 1024, 768);

      EditAddCustomersView.frame=CGRectMake(100, 150, EditCustomersBackView.frame.size.width-200, EditCustomersBackView.frame.size.height-350);
       
          //  EditAddCustomersView.frame=CGRectMake(20, 200, EditCustomersBackView.frame.size.width-40, EditCustomersBackView.frame.size.height-650);
        
    

    CGFloat EditcustomerW=(EditAddCustomersView.frame.size.width)/4;
    CGFloat Edit=(EditcustomerW/2)+20;
    
    EditCustomerLbl.frame=CGRectMake(Edit-80, 30,EditcustomerW, 50);
    EditCustomerField.frame=CGRectMake(EditcustomerW-5, 35,EditcustomerW, 40);
  
    EditLastnamelbl.frame=CGRectMake(Edit-80, 100,EditcustomerW, 50);
    
    EditLastnameField.frame=CGRectMake(EditcustomerW-5, 105,EditcustomerW, 40);

    Editfirstnamelbl.frame=CGRectMake(EditcustomerW+5+EditLastnameField.frame.size.width+10, 30,EditcustomerW, 50);

    EditFirstnameField.frame=CGRectMake(EditcustomerW-15+EditLastnameField.frame.size.width+Editfirstnamelbl.frame.size.width, 35,EditcustomerW, 40);
   
    EditEmaillbl.frame=CGRectMake(EditcustomerW+5+EditLastnameField.frame.size.width+10, 100,EditcustomerW, 50);
    
    
    EditEmailField.frame=CGRectMake(EditcustomerW-15+EditLastnameField.frame.size.width+Editfirstnamelbl.frame.size.width, 105,EditcustomerW, 40);
   
    
    CGFloat Ewdth=(EditAddCustomersView.frame.size.width)/7;
    CGFloat Exvalue=Ewdth/4;
    for (int k=0; k<6; k++)
    {
       
        UIButton *mybtn=(UIButton *)[EditAddCustomersView viewWithTag:k+100];
        mybtn.frame=CGRectMake(Exvalue-13,200,Ewdth+5, 40);
        [EditAddCustomersView addSubview:mybtn];
        Exvalue=Exvalue+Ewdth+12;
        
    }
    
    EditSavecustomerBtn.frame=CGRectMake(EditcustomerW+100, 300, 80, 30);
    EditCancelCustomerBtn.frame=CGRectMake(EditcustomerW+220, 300, 80, 30);
    
        
        
//History View
        
        HistoryPopupView.frame=CGRectMake(0, 0, 1024, 768);
    
       // HistoryPopupView.frame=CGRectMake(0, 0, 768, 1024);
    
        HistoryView.frame=CGRectMake(50, 100, HistoryPopupView.frame.size.width-100, HistoryPopupView.frame.size.height-200);
   
        //HistoryView.frame=CGRectMake(50, 150, HistoryPopupView.frame.size.width-100, HistoryPopupView.frame.size.height-400);
    
    CGFloat widthfield5=(HistoryView.frame.size.width)/4;
   
    Historytextlbl.frame=CGRectMake(widthfield5+120,10,widthfield5,40);
   
    
    SalesHistoryTable.frame = CGRectMake(10,60,HistoryView.frame.size.width-20, 400);

    saveHistoryBtn.frame=CGRectMake(widthfield5+160,500,80,30);
        
    
    
    
    }
    else
    {
        CGFloat width,height;
        height=1004;
        width=768;
        // //NSLog(@" %f,%f",width,height);
        
        
        backgroundcolorview.frame=CGRectMake(0,y,width,height-100);
        navBar.frame=CGRectMake(0, 0,width , 50.0);
        
        [logoBtn setFrame:CGRectMake(60,0,250,50)];
        
        sationLbl.frame=CGRectMake(navBar.frame.size.width-280, 5,100, 40);
        EmpIdlbl.frame=CGRectMake(navBar.frame.size.width-193, 5,150, 40);
        Timelbl.frame=CGRectMake(navBar.frame.size.width-62, 6,80, 40);
        
        //sidemenu.frame=CGRectMake(0, 1,170 ,height-150);
        // sidemenu.hidden=YES;
        [categorybutton setFrame:CGRectMake(0.0,p,170,40)];
        mainview.frame=CGRectMake(20,60,width-40,height-200);
        [menubutton setFrame:CGRectMake(0,0,50,50)];
        
        maintoolBar.frame = CGRectMake(0, 0, mainview.frame.size.width, 40);
        //downtoolBar.frame = CGRectMake(0, 0, mainview.frame.size.width, 40);
        
        logoimageview.frame=CGRectMake(50, (backgroundcolorview.frame.size.height)+5+y,(height-(backgroundcolorview.frame.size.height)-30), (height-(backgroundcolorview.frame.size.height)-30));
        
        [helpiconButton setFrame:CGRectMake(width-180,(backgroundcolorview.frame.size.height)+10+y,70,70)];
        
        
        [logouticonButton setFrame:CGRectMake(width-100,(backgroundcolorview.frame.size.height)+10+y,70,70)];
        
        
        
   //Customers View
        
        
        CustomersBackView.frame=CGRectMake(10, 0, mainview.frame.size.width-20, (mainview.frame.size.height));
        
        
        CGFloat addbuttonwidth=(CustomersBackView.frame.size.width-10)/2;
        AddCustomerBtn.frame=CGRectMake(10, 10, addbuttonwidth, 40);
        
        EditCustomerBtn.frame=CGRectMake(AddCustomerBtn.frame.size.width, 10, addbuttonwidth, 40);
        
        
        AddCustomersView.frame=CGRectMake(10, AddCustomerBtn.frame.size.height+10, CustomersBackView.frame.size.width-20, CustomersBackView.frame.size.height-20-AddCustomerBtn.frame.size.height);
        CGFloat customerW=(AddCustomersView.frame.size.width)/4;
        CGFloat r=(customerW/2)+20;
    
        CustomerLbl.frame=CGRectMake(r-80, 30,customerW, 50);
        
        CustomerField.frame=CGRectMake(customerW-5, 35,customerW, 40);
        Lastnamelbl.frame=CGRectMake(r-80, 100,customerW, 50);
    
        LastnameField.frame=CGRectMake(customerW-5, 105,customerW, 40);

        firstnamelbl.frame=CGRectMake(customerW+5+LastnameField.frame.size.width+10, 30,customerW, 50);
        
        
        FirstnameField.frame=CGRectMake(customerW-15+LastnameField.frame.size.width+firstnamelbl.frame.size.width, 35,customerW, 40);
        
        Emaillbl.frame=CGRectMake(customerW+5+LastnameField.frame.size.width+10, 100,customerW, 50);
        
        EmailField.frame=CGRectMake(customerW-15+LastnameField.frame.size.width+firstnamelbl.frame.size.width, 105,customerW, 40);
        
        
        CGFloat wdth=(AddCustomersView.frame.size.width)/7;
        CGFloat xvalue=wdth/4;
        for (int k=0; k<6; k++)
        {
            
            UIButton *mybtn=(UIButton *)[AddCustomersView viewWithTag:k+100];
            mybtn.frame=CGRectMake(xvalue-13,200,wdth+5, 40);
            [AddCustomersView addSubview:mybtn];
            
            xvalue=xvalue+wdth+12;
            
        }
        SavecustomerBtn.frame=CGRectMake(customerW+100, 300, 80, 30);
        CancelCustomerBtn.frame=CGRectMake(customerW+220, 300, 80, 30);
        
        [[customerPaginationObject  paginationsegment] setFrame:CGRectMake(10, AddCustomerBtn.frame.size.height+10,CustomersBackView.frame.size.width-20, 40)];
        
        EditCustomerTable.frame=CGRectMake(10, AddCustomerBtn.frame.size.height+50, CustomersBackView.frame.size.width-20, CustomersBackView.frame.size.height-20-AddCustomerBtn.frame.size.height-40);
        
//General Info View
        
        GeneralInfoPopUp.frame=CGRectMake(0, 0, 768, 1024);
        
       GeneralInfoView.frame=CGRectMake(50, 150, GeneralInfoPopUp.frame.size.width-100, GeneralInfoPopUp.frame.size.height-500);
        
        GeneralInfoView.contentSize=CGSizeMake(GeneralInfoPopUp.frame.size.width-100, GeneralInfoPopUp.frame.size.height);
        CGFloat fieldwidth=(GeneralInfoView.frame.size.width)/4;
         GeneralInfoTextlbl.frame=CGRectMake(fieldwidth+60, 10,fieldwidth+100, 40);
        CGFloat o=(fieldwidth/2);
        int d=60;
        
        for (int i=0; i<5; i++)
        {
            UILabel *mylabel=(UILabel *)[GeneralInfoView viewWithTag:i+100];
            mylabel.frame=CGRectMake(o-60, d,fieldwidth+10, 40);
            [GeneralInfoView addSubview:mylabel];
            
            UITextField *mytextfield=(UITextField *)[GeneralInfoView viewWithTag:i+100];
            mytextfield.frame=CGRectMake(mylabel.frame.size.width+5, d,fieldwidth-10, 40);
            [GeneralInfoView addSubview:mytextfield];
            
            
            d=d+60;
            
        }
        
        int b=60;
        
        for (int i=0; i<5; i++)
        {
            
            
            UILabel *mylabel=(UILabel *)[GeneralInfoView viewWithTag:i+100];
            mylabel.frame=CGRectMake(GeneralInfolbl.frame.size.width+5+GeneralInfoField.frame.size.width+5, b,fieldwidth+10, 40);
            [GeneralInfoView addSubview:mylabel];
            
            UITextField *mytextfield=(UITextField *)[GeneralInfoView viewWithTag:i+100];
            mytextfield.frame=CGRectMake(GeneralInfolbl.frame.size.width+GeneralInfoField.frame.size.width+mylabel.frame.size.width-5, b,fieldwidth-10, 40);
            [GeneralInfoView addSubview:mytextfield];
            
            b=b+60;
            
        }
        
        SaveGeneralInfoBtn.frame=CGRectMake(fieldwidth+80, 400, 80, 30);
        CancelGeneralInfoBtn.frame=CGRectMake(fieldwidth+240, 400, 80, 30);
        
//Extended View
        
        ExtendedInfopopUp.frame=CGRectMake(0, 0, 768, 1024);
        
       ExtendedInfoView.frame=CGRectMake(50, 150, ExtendedInfopopUp.frame.size.width-100, ExtendedInfopopUp.frame.size.height-500);
        ExtendedInfoView.contentSize=CGSizeMake(ExtendedInfopopUp.frame.size.width-100, ExtendedInfopopUp.frame.size.height);
        
        
        
        CGFloat Efieldwidth=(ExtendedInfoView.frame.size.width)/4;
        
        CGFloat E=(Efieldwidth/2);
        
        ExdInfotextlbl.frame=CGRectMake(Efieldwidth+60, 10,Efieldwidth+100, 40);
        
        
        CreditcardInfolbl.frame=CGRectMake(Efieldwidth-40, 50,Efieldwidth+50, 40);
        
        PersonalInfolbl.frame=CGRectMake(Efieldwidth+CreditcardInfolbl.frame.size.width+40, 50,Efieldwidth+100, 40);
        
        
        int k=100;
        
        for (int i=0; i<2; i++)
        {
            
            
            UILabel *mylabel=(UILabel *)[ExtendedInfoView viewWithTag:i+100];
            mylabel.frame=CGRectMake(E-70, k,Efieldwidth+10, 40);
            [ExtendedInfoView addSubview:mylabel];
            
            UITextField *mytextfield=(UITextField *)[ExtendedInfoView viewWithTag:i+100];
            mytextfield.frame=CGRectMake(mylabel.frame.size.width+5, k,Efieldwidth-10, 40);
            [ExtendedInfoView addSubview:mytextfield];
            
            k=k+70;
            
        }
        CreditCardtypelbl.frame=CGRectMake(E-70, 240,Efieldwidth+10, 40);
        
        CreditCardTypeBtn.frame=CGRectMake(ExtendedInfolbl.frame.size.width+5, 240,Efieldwidth-10, 40);
        CreadidCardListTable.frame =CGRectMake(ExtendedInfolbl.frame.size.width+5, 280,Efieldwidth-10, 100);
        
        int s=100;
        
        for (int i=0; i<4; i++)
        {
            
            UILabel *mylabel=(UILabel *)[ExtendedInfoView viewWithTag:i+100];
            mylabel.frame=CGRectMake(ExtendedInfolbl.frame.size.width+5+ExtendedField.frame.size.width+5, s,Efieldwidth+10, 40);
            [ExtendedInfoView addSubview:mylabel];
            
            UITextField *mytextfield=(UITextField *)[ExtendedInfoView viewWithTag:i+100];
            mytextfield.frame=CGRectMake(ExtendedInfolbl.frame.size.width+ExtendedField.frame.size.width+mylabel.frame.size.width-15, s,Efieldwidth-10, 40);
            [ExtendedInfoView addSubview:mytextfield];
            
            s=s+70;
            
        }
        
        SaveExtendedInfoBtn.frame=CGRectMake(Efieldwidth+80, 420, 80, 30);
        CancelExtendedInfoBtn.frame=CGRectMake(Efieldwidth+230, 420, 80, 30);
        
//Notes View
        
        NotesBackView.frame=CGRectMake(0, 0, 768, 1024);
        
       NotesView.frame=CGRectMake(50, 150, NotesBackView.frame.size.width-100, NotesBackView.frame.size.height-400);
        
        CGFloat widthfield3=(NotesView.frame.size.width)/4;
        
        Notestextlbl.frame=CGRectMake(widthfield3+100,10,widthfield3,40);
        
        EnterNoteslbl.frame=CGRectMake(widthfield3-60,60,widthfield3,40);
        
        NotesTextView.frame=CGRectMake(10, 115,NotesView.frame.size.width-20,400);
        
        
        SaveNotesBtn.frame=CGRectMake(widthfield3+80,540,80,30);
        
        CancelNotesBtn.frame=CGRectMake(widthfield3+230,540,80,30);

        
//Shpping View
        
        
        ShippingInfoPopUp.frame=CGRectMake(0, 0, 768, 1024);
       ShippingInfoView.frame=CGRectMake(50, 200, ShippingInfoPopUp.frame.size.width-100, ShippingInfoPopUp.frame.size.height-500);
        ShippingInfoView.contentSize=CGSizeMake(ShippingInfoPopUp.frame.size.width-100, ShippingInfoPopUp.frame.size.height);
        
        
        CGFloat fieldwidth2=(ShippingInfoView.frame.size.width)/4;
        
        CGFloat sh=(fieldwidth2/2);
        ShippingInfoTextlbl.frame=CGRectMake(fieldwidth2+60, 10,fieldwidth2+100, 40);
        
        int l=60;
        
        for (int i=0; i<5; i++)
        {
            
            
            UILabel *mylabel=(UILabel *)[ShippingInfoView viewWithTag:i+100];
            mylabel.frame=CGRectMake(sh-60, l,fieldwidth2+10, 40);
            [ShippingInfoView addSubview:mylabel];
            
            UITextField *mytextfield=(UITextField *)[ShippingInfoView viewWithTag:i+100];
            mytextfield.frame=CGRectMake(mylabel.frame.size.width+5, l,fieldwidth2-10, 40);
            [ShippingInfoView addSubview:mytextfield];
            
            
            l=l+60;
            
        }
        
        int m=60;
        
        for (int i=0; i<5; i++)
        {
            
            UILabel *mylabel=(UILabel *)[ShippingInfoView viewWithTag:i+100];
            mylabel.frame=CGRectMake(ShippingInfolbl.frame.size.width+5+ShippingInfoField.frame.size.width+5, m,fieldwidth2+10, 40);
            [ShippingInfoView addSubview:mylabel];
            
            UITextField *mytextfield=(UITextField *)[ShippingInfoView viewWithTag:i+100];
            mytextfield.frame=CGRectMake(ShippingInfolbl.frame.size.width+ShippingInfoField.frame.size.width+mylabel.frame.size.width-5, m,fieldwidth2-10, 40);
            [ShippingInfoView addSubview:mytextfield];
            
            
            m=m+60;
            
        }
        
        SaveShippingInfoBtn.frame=CGRectMake(fieldwidth2+80, 400, 80, 30);
        CancelShippingInfoBtn.frame=CGRectMake(fieldwidth2+220, 400, 80, 30);
        
//Stores View
        StoresPopupView.frame=CGRectMake(0, 0, 768, 1024);
        
       StoresView.frame=CGRectMake(50, 150, StoresPopupView.frame.size.width-100, StoresPopupView.frame.size.height-400);
        
        CGFloat widthfield4=(StoresView.frame.size.width)/4;
        StoresTextlbl.frame=CGRectMake(widthfield4+100,10,widthfield4,40);
        
        Storeslbl.frame=CGRectMake(20, 155,widthfield4+10, 40);
        
        StoresBtn.frame=CGRectMake(Storeslbl.frame.size.width-40, 150,widthfield4+10, 40);
        StoresListTable .frame= CGRectMake(Storeslbl.frame.size.width-40, 50,widthfield4+10, 100);
        StoresDataTable .frame= CGRectMake(50, 200,StoresView.frame.size.width-100, 300);
        SavestoresBtn.frame=CGRectMake(widthfield4+100,540,80,30);
        CancelStoresBtn.frame=CGRectMake(widthfield4+230,540,80,30);
        
        
        
//Edit customer view
        
        EditCustomersBackView.frame=CGRectMake(0, 0, 768, 1024);
        
        
       EditAddCustomersView.frame=CGRectMake(20, 200, EditCustomersBackView.frame.size.width-40, EditCustomersBackView.frame.size.height-650);
        
        
        CGFloat EditcustomerW=(EditAddCustomersView.frame.size.width)/4;
        CGFloat Edit=(EditcustomerW/2)+20;
        
        EditCustomerLbl.frame=CGRectMake(Edit-80, 30,EditcustomerW, 50);
        EditCustomerField.frame=CGRectMake(EditcustomerW-5, 35,EditcustomerW, 40);
        
        EditLastnamelbl.frame=CGRectMake(Edit-80, 100,EditcustomerW, 50);
        
        EditLastnameField.frame=CGRectMake(EditcustomerW-5, 105,EditcustomerW, 40);
        
        Editfirstnamelbl.frame=CGRectMake(EditcustomerW+5+EditLastnameField.frame.size.width+10, 30,EditcustomerW, 50);
        
        EditFirstnameField.frame=CGRectMake(EditcustomerW-15+EditLastnameField.frame.size.width+Editfirstnamelbl.frame.size.width, 35,EditcustomerW, 40);
        
        EditEmaillbl.frame=CGRectMake(EditcustomerW+5+EditLastnameField.frame.size.width+10, 100,EditcustomerW, 50);
        
        
        EditEmailField.frame=CGRectMake(EditcustomerW-15+EditLastnameField.frame.size.width+Editfirstnamelbl.frame.size.width, 105,EditcustomerW, 40);
        
        
        CGFloat Ewdth=(EditAddCustomersView.frame.size.width)/7;
        CGFloat Exvalue=Ewdth/4;
        for (int k=0; k<6; k++)
        {
            
            UIButton *mybtn=(UIButton *)[EditAddCustomersView viewWithTag:k+100];
            mybtn.frame=CGRectMake(Exvalue-13,200,Ewdth+5, 40);
            [EditAddCustomersView addSubview:mybtn];
            Exvalue=Exvalue+Ewdth+12;
            
        }
        
        EditSavecustomerBtn.frame=CGRectMake(EditcustomerW+100, 300, 80, 30);
        EditCancelCustomerBtn.frame=CGRectMake(EditcustomerW+220, 300, 80, 30);
        
        
//History View
        
        //HistoryPopupView.frame=CGRectMake(0, 0, 1024, 768);
        
         HistoryPopupView.frame=CGRectMake(0, 0, 768, 1024);
        
        //HistoryView.frame=CGRectMake(50, 100, HistoryPopupView.frame.size.width-100, HistoryPopupView.frame.size.height-200);
        
        HistoryView.frame=CGRectMake(50, 150, HistoryPopupView.frame.size.width-100, HistoryPopupView.frame.size.height-400);
        
        CGFloat widthfield5=(HistoryView.frame.size.width)/4;
        
        Historytextlbl.frame=CGRectMake(widthfield5+120,10,widthfield5,40);

        SalesHistoryTable.frame = CGRectMake(10,60,HistoryView.frame.size.width-20, 400);
        
        saveHistoryBtn.frame=CGRectMake(widthfield5+160,500,80,30);
        
        
        
    }
    
}

-(void)menuclicked
{
    if (menuslected == false)
    {
        
        // //NSLog(@"called");
        // //NSLog(@"%d",menuslected);
        menuslected=YES;
        
        logoBtn.hidden=YES;
      //  [UIView beginAnimations:nil context:NULL];
      //  [UIView setAnimationDuration:1.0f];
        sidemenu.transform = CGAffineTransformMakeTranslation(0,0);
        //[SideMenuView setBackgroundColor:[UIColor whiteColor]];
     //   //sidemenu.hidden=NO;
      //  [UIView commitAnimations];
        [backgroundcolorview addSubview:sidemenu];
        
      ///  [UIView beginAnimations:nil context:NULL];
//[UIView setAnimationDuration:0.9f];
        menubutton.transform = CGAffineTransformMakeTranslation(180,0);
        
        menubutton.transform = CGAffineTransformRotate( menubutton.transform, - M_PI);
       // [UIView commitAnimations];
       // [UIView beginAnimations:nil context:NULL];
      //  [UIView setAnimationDuration:1.0f];
        
        
    }else
    {
        
        logoBtn.hidden=NO;
        menuslected=NO;
        
        //[UIView beginAnimations:nil context:NULL];
       // [UIView setAnimationDuration:1.0f];
        sidemenu.transform = CGAffineTransformMakeTranslation(-250,0);
        
        //[UIView commitAnimations];
        
        
        
        
       // [UIView beginAnimations:nil context:NULL];
       // [UIView setAnimationDuration:1.0f];
        menubutton.transform = CGAffineTransformMakeTranslation(0,0);
        
        
        //[UIView commitAnimations];
       // [UIView beginAnimations:nil context:NULL];
       // [UIView setAnimationDuration:1.0f];
        
    }
    
}

-(void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event {
    
    logoBtn.hidden=NO;
  // // [UIView beginAnimations:nil context:NULL];
   // [UIView setAnimationDuration:0.8f];
    mainview.transform = CGAffineTransformMakeTranslation(0,0);
    
    
   // [UIView commitAnimations];
   // [UIView beginAnimations:nil context:NULL];
   // [UIView setAnimationDuration:0.8f];
    sidemenu.transform = CGAffineTransformMakeTranslation(-250,0);
    //[SideMenuView setBackgroundColor:[UIColor whiteColor]];
    
//    [UIView commitAnimations];
//    [UIView commitAnimations];
//    [UIView beginAnimations:nil context:NULL];
//    [UIView setAnimationDuration:0.0f];
    menubutton.transform = CGAffineTransformMakeTranslation(0,0);
    
    
//    [UIView commitAnimations];
//    [UIView beginAnimations:nil context:NULL];
//    [UIView setAnimationDuration:0.0f];
    menuslected=NO;
}
- (BOOL)textFieldShouldBeginEditing:(UITextField *)textField
{
    if(textField == EditCustomerField)
    {
        [textField resignFirstResponder];
        // Show you custom picker here....
        return NO;
    }
    return YES;
}
-(void)helpiconclicked
{
    
}
-(void)logoutButtonClicked
{
       [serverSyncClassObject LogoutMethod];
    NSString *updateSQL =@"UPDATE miscellaneous SET userType=?,sessionId=?,userID=?";
    NSMutableArray *misUpdatearray=[[NSMutableArray alloc]initWithObjects:@"",@"",@"", nil];
    [[DataBaseManager dataBaseManager] executeRecordsWithQuery:updateSQL withArguments:misUpdatearray];
    [self.navigationController popToRootViewControllerAnimated:YES];
    [self releaseViews];
    [generalDataObject  releasevariable];
}
-(void)categotybuttonclicked:(UIButton *)sender
{
    NSArray *viewS = [self.navigationController viewControllers];
    //NSLog(@"nav views %@",viewS);
    NSInteger selectedrow=sender.tag;
    if(selectedrow == 0){
        Home *homeview=[[Home alloc]initWithNibName:@"Home" bundle:Nil];
        NSString *returnvalue;
        NSInteger selectedview;
        for (int m=0;m<[self.navigationController.viewControllers count] ; m++)
        {
            if([[self.navigationController.viewControllers objectAtIndex:m] isKindOfClass:[Home class]])
            {
                returnvalue=@"yes";
                selectedview=m;
                break;
            }
            
        }
        ////NSLog(@"%d",selectedview);
        if([returnvalue isEqualToString:@"yes"])
        {
            [self.navigationController popToViewController:[viewS objectAtIndex:selectedview] animated:YES];
            [self releaseViews];
        }else{
            
            [self.navigationController pushViewController:homeview animated:NO];
            [self releaseViews];
        }
        
    }else if(selectedrow == 5){
        if ([[generalDataObject  userType] isEqualToString:@"employee"])
        {
            if ([[generalDataObject  settings_permission] isEqualToString:@"yes"])
            {
                [sender setImage:[UIImage imageNamed:@"settingsactive2.png"] forState:UIControlStateNormal];
                NSString *returnvalue;
                NSInteger selectedview;
                Settings  *settingsview=[[Settings alloc]initWithNibName:@"Settings" bundle:Nil];
                for (int m=0;m<[self.navigationController.viewControllers count] ; m++)
                {
                    if([[self.navigationController.viewControllers objectAtIndex:m] isKindOfClass:[Settings class]])
                    {
                        returnvalue=@"yes";
                        selectedview=m;
                        break;
                    }
                    
                }
                if([returnvalue isEqualToString:@"yes"])
                {
                    [self.navigationController popToViewController:[viewS objectAtIndex:selectedview] animated:YES];
                    [self releaseViews];
                }else
                {
                    
                    [self.navigationController pushViewController:settingsview animated:NO];
                    [self releaseViews];
                }
                
            }else{
                
                UIAlertView *authalert=[[UIAlertView alloc]initWithTitle:@"Authentication:" message:@"User not authenticated" delegate:self cancelButtonTitle:@"ok" otherButtonTitles:Nil, nil];
                
                [authalert show];
            }
        }else{
            [sender setImage:[UIImage imageNamed:@"settingsactive2.png"] forState:UIControlStateNormal];
            NSString *returnvalue;
            NSInteger selectedview;
            Settings  *settingsview=[[Settings alloc]initWithNibName:@"Settings" bundle:Nil];
            for (int m=0;m<[self.navigationController.viewControllers count] ; m++)
            {
                if([[self.navigationController.viewControllers objectAtIndex:m] isKindOfClass:[Settings class]])
                {
                    returnvalue=@"yes";
                    selectedview=m;
                    break;
                }
                
            }
            if([returnvalue isEqualToString:@"yes"])
            {
                [self.navigationController popToViewController:[viewS objectAtIndex:selectedview] animated:YES];
                [self releaseViews];
            }else
            {
                [self.navigationController pushViewController:settingsview animated:NO];
                [self releaseViews];
            }
            
            
        }
        
        
    }else if(selectedrow == 8){
        NSString *returnvalue;
        NSInteger selectedview;
        Stores *storesview=[[Stores alloc]initWithNibName:@"Stores" bundle:Nil];
        for (int m=0;m<[self.navigationController.viewControllers count] ; m++)
        {
            if([[self.navigationController.viewControllers objectAtIndex:m] isKindOfClass:[Stores class]])
            {
                returnvalue=@"yes";
                selectedview=m;
                break;
            }
            
        }
        if([returnvalue isEqualToString:@"yes"])
        {
            [self.navigationController popToViewController:[viewS objectAtIndex:selectedview] animated:YES];
            [self releaseViews];
        }else
        {
            
            [self.navigationController pushViewController:storesview animated:NO];
            [self releaseViews];
        }
    }else if(selectedrow == 2){
        
        if ([[generalDataObject  userType] isEqualToString:@"employee"])
        {
            if ([[generalDataObject  inventory_permission] isEqualToString:@"yes"])
            {
                NSString *returnvalue;
                NSInteger selectedview;
                Inventory *inventoryview=[[Inventory alloc]initWithNibName:@"Inventory" bundle:Nil];
                for (int m=0;m<[self.navigationController.viewControllers count] ; m++)
                {
                    if([[self.navigationController.viewControllers objectAtIndex:m] isKindOfClass:[Inventory class]])
                    {
                        returnvalue=@"yes";
                        selectedview=m;
                        break;
                    }
                    
                }
                if([returnvalue isEqualToString:@"yes"])
                {
                    [self.navigationController popToViewController:[viewS objectAtIndex:selectedview] animated:YES];
                    [self releaseViews];
                }else
                {
                    
                    [self.navigationController pushViewController:inventoryview animated:NO];
                    [self releaseViews];
                }
                
            }else{
                
                UIAlertView *authalert=[[UIAlertView alloc]initWithTitle:@"Authentication:" message:@"User not authenticated" delegate:self cancelButtonTitle:@"ok" otherButtonTitles:Nil, nil];
                
                [authalert show];
            }
        }
        else
        {
            
            NSString *returnvalue;
            NSInteger selectedview;
            Inventory *inventoryview=[[Inventory alloc]initWithNibName:@"Inventory" bundle:Nil];
            for (int m=0;m<[self.navigationController.viewControllers count] ; m++)
            {
                if([[self.navigationController.viewControllers objectAtIndex:m] isKindOfClass:[Inventory class]])
                {
                    returnvalue=@"yes";
                    selectedview=m;
                    break;
                }
                
            }
            if([returnvalue isEqualToString:@"yes"])
            {
                [self.navigationController popToViewController:[viewS objectAtIndex:selectedview] animated:YES];
                [self releaseViews];
            }else
            {
                
                [self.navigationController pushViewController:inventoryview animated:NO];
                [self releaseViews];
            }
        }
    }else if(selectedrow == 1){
        if ([[generalDataObject  userType] isEqualToString:@"admin"])
        {
            NSString *returnvalue;
            NSInteger selectedview;
            Profile *profileview=[[Profile alloc]initWithNibName:@"Profile" bundle:Nil];
            for (int m=0;m<[self.navigationController.viewControllers count] ; m++)
            {
                if([[self.navigationController.viewControllers objectAtIndex:m] isKindOfClass:[Profile class]])
                {
                    returnvalue=@"yes";
                    selectedview=m;
                    break;
                }
                
            }
            if([returnvalue isEqualToString:@"yes"])
            {
                [self.navigationController popToViewController:[viewS objectAtIndex:selectedview] animated:YES];
                [self releaseViews];
            }else
            {
                
                [self.navigationController pushViewController:profileview animated:NO];
                [self releaseViews];
            }
            
        }else{
            UIAlertView *authalert=[[UIAlertView alloc]initWithTitle:@"Authentication:" message:@"User not authenticated" delegate:self cancelButtonTitle:@"ok" otherButtonTitles:Nil, nil];
            
            [authalert show];
            authalert=nil;
        }
    }else if(selectedrow == 4){
        if ([[generalDataObject  userType] isEqualToString:@"admin"])
        {
            NSString *returnvalue;
            NSInteger selectedview;
            Employees *employeesview=[[Employees alloc]initWithNibName:@"Employees" bundle:Nil];
            for (int m=0;m<[self.navigationController.viewControllers count] ; m++)
            {
                if([[self.navigationController.viewControllers objectAtIndex:m] isKindOfClass:[Employees class]])
                {
                    returnvalue=@"yes";
                    selectedview=m;
                    break;
                }
                
            }
            if([returnvalue isEqualToString:@"yes"])
            {
                [self.navigationController popToViewController:[viewS objectAtIndex:selectedview] animated:YES];
                [self releaseViews];
            }else
            {
                
                [self.navigationController pushViewController:employeesview animated:NO];
                [self releaseViews];
            }

            
        }
        else
        {
            UIAlertView *authalert=[[UIAlertView alloc]initWithTitle:@"Authentication:" message:@"User not authenticated" delegate:self cancelButtonTitle:@"ok" otherButtonTitles:Nil, nil];
            
            [authalert show];
        }
        
    }else if(selectedrow == 6){
        
        if ([[generalDataObject  userType] isEqualToString:@"employee"])
        {
            if ([[generalDataObject  settings_permission] isEqualToString:@"yes"])
            {
                NSString *returnvalue;
                NSInteger selectedview;
                Reports *reportsview=[[Reports alloc]initWithNibName:@"Reports" bundle:Nil];
                for (int m=0;m<[self.navigationController.viewControllers count] ; m++)
                {
                    if([[self.navigationController.viewControllers objectAtIndex:m] isKindOfClass:[Reports class]])
                    {
                        returnvalue=@"yes";
                        selectedview=m;
                        break;
                    }
                    
                }
                if([returnvalue isEqualToString:@"yes"])
                {
                    [self.navigationController popToViewController:[viewS objectAtIndex:selectedview] animated:YES];
                    [self releaseViews];
                }else
                {
                    
                    [self.navigationController pushViewController:reportsview animated:NO];
                    [self releaseViews];
                }
                
            }else{
                
                UIAlertView *authalert=[[UIAlertView alloc]initWithTitle:@"Authentication:" message:@"User not authenticated" delegate:self cancelButtonTitle:@"ok" otherButtonTitles:Nil, nil];
                
                [authalert show];
            }
        }else{
            
            NSString *returnvalue;
            NSInteger selectedview;
            Reports *reportsview=[[Reports alloc]initWithNibName:@"Reports" bundle:Nil];
            for (int m=0;m<[self.navigationController.viewControllers count] ; m++)
            {
                if([[self.navigationController.viewControllers objectAtIndex:m] isKindOfClass:[Reports class]])
                {
                    returnvalue=@"yes";
                    selectedview=m;
                    break;
                }
                
            }
            if([returnvalue isEqualToString:@"yes"])
            {
                [self.navigationController popToViewController:[viewS objectAtIndex:selectedview] animated:YES];
                [self releaseViews];
            }else
            {
                
                [self.navigationController pushViewController:reportsview animated:NO];
                [self releaseViews];
            }
            
        }
        
    }else if(selectedrow == 7){
        NSString *returnvalue;
        NSInteger selectedview;
        Contacts *contactsview=[[Contacts alloc]initWithNibName:@"Contacts" bundle:Nil];
        for (int m=0;m<[self.navigationController.viewControllers count] ; m++)
        {
            if([[self.navigationController.viewControllers objectAtIndex:m] isKindOfClass:[Contacts class]])
            {
                returnvalue=@"yes";
                selectedview=m;
                break;
            }
            
        }
        if([returnvalue isEqualToString:@"yes"])
        {
            [self.navigationController popToViewController:[viewS objectAtIndex:selectedview] animated:YES];
            [self releaseViews];
        }else
        {
            
            [self.navigationController pushViewController:contactsview animated:NO];
            [self releaseViews];
        }
    }
       
}

-(void)releaseViews
{
    NSArray *mainArray = self.view.subviews;
    for (int i = 0; i<[mainArray count]; i++) {
        UIView *vi =[mainArray objectAtIndex:i];
        [vi removeFromSuperview];
        vi = nil;
    }
    
    NSArray *sideArray = sidemenu.subviews;
    for (int i = 0; i<[sideArray count]; i++) {
        UIView *vi =[sideArray objectAtIndex:i];
        [vi removeFromSuperview];
        vi = nil;
    }
    
    NSArray *navBarArray = navBar.subviews;
    for (int i = 0; i<[navBarArray count]; i++) {
        UIView *vi =[navBarArray objectAtIndex:i];
        [vi removeFromSuperview];
        vi = nil;
    }
    [sidemenu removeFromSuperview],[mainview removeFromSuperview],[backgroundcolorview removeFromSuperview];
    sidemenu =nil, mainview =nil, backgroundcolorview =nil;
    categorybutton =nil;
    downtoolBar =nil, maintoolBar =nil;
    logobackview =nil, logoimageview =nil;
    
    helpiconButton =nil, logouticonButton =nil, menubutton =nil;
    
    backButton3 =nil, backButton2 =nil, backButton =nil;
    navBar =nil;
    NSArray *AddCustomersViewArray = AddCustomersView.subviews;
    for (int i = 0; i<[AddCustomersViewArray count]; i++) {
        UIView *vi =[AddCustomersViewArray objectAtIndex:i];
        [vi removeFromSuperview];
        vi = nil;
    }
    
    NSArray *CustomersBackViewArray = CustomersBackView.subviews;
    for (int i = 0; i<[CustomersBackViewArray count]; i++) {
        UIView *vi =[CustomersBackViewArray objectAtIndex:i];
        [vi removeFromSuperview];
        vi = nil;
    }
    [AddCustomersView removeFromSuperview],[CustomersBackView removeFromSuperview];
    CustomersBackView =nil;
    AddCustomersView =nil;
    AddCustomerBtn =nil, EditCustomerBtn =nil;
    
    CustomerLbl =nil, firstnamelbl =nil, Lastnamelbl =nil, Emaillbl =nil;
    CustomerField =nil, FirstnameField =nil, LastnameField =nil, EmailField =nil;
    CustomerInfoBtn =nil;
    SavecustomerBtn =nil, CancelCustomerBtn =nil;
    EditCustomerTable =nil;
    EditBtn =nil, DeleteBtn =nil;
    
    deleteCustomerAlert =nil;
    
    [CustomerNosArray  removeAllObjects], [CuFirstnamesArray  removeAllObjects], [CuLastnamesArray  removeAllObjects], [EmailsArray  removeAllObjects], [CustomerNotesArray  removeAllObjects];
    CustomerNosArray =nil, CuFirstnamesArray =nil, CuLastnamesArray =nil, EmailsArray =nil, CustomerNotesArray =nil;
    //Edit Customer View
    NSArray *EditAddCustomersViewArray = EditAddCustomersView.subviews;
    for (int i = 0; i<[EditAddCustomersViewArray count]; i++) {
        UIView *vi =[EditAddCustomersViewArray objectAtIndex:i];
        [vi removeFromSuperview];
        vi = nil;
    }
    
    NSArray *EditCustomersBackViewArray = EditCustomersBackView.subviews;
    for (int i = 0; i<[EditCustomersBackViewArray count]; i++) {
        UIView *vi =[EditCustomersBackViewArray objectAtIndex:i];
        [vi removeFromSuperview];
        vi = nil;
    }
    [AddCustomersView removeFromSuperview],[EditCustomersBackView removeFromSuperview];
    EditCustomersBackView =nil;
    EditAddCustomersView =nil;
    EditCustomerLbl =nil, Editfirstnamelbl =nil, EditLastnamelbl =nil, EditEmaillbl =nil;
    EditCustomerField =nil, EditFirstnameField =nil, EditLastnameField =nil, EditEmailField =nil;
    EditCustomerInfoBtn =nil;
    EditSavecustomerBtn =nil, EditCancelCustomerBtn =nil;
    
    
    
    //GeneralInfo View
    NSArray *GeneralInfoViewArray = GeneralInfoView.subviews;
    for (int i = 0; i<[GeneralInfoViewArray count]; i++) {
        UIView *vi =[GeneralInfoViewArray objectAtIndex:i];
        [vi removeFromSuperview];
        vi = nil;
    }
    
    NSArray *GeneralInfoPopUpArray = GeneralInfoPopUp.subviews;
    for (int i = 0; i<[GeneralInfoPopUpArray count]; i++) {
        UIView *vi =[GeneralInfoPopUpArray objectAtIndex:i];
        [vi removeFromSuperview];
        vi = nil;
    }
    [GeneralInfoView removeFromSuperview],[GeneralInfoPopUp removeFromSuperview];
    GeneralInfoPopUp =nil;
    GeneralInfoView =nil;
    GeneralInfoField =nil, GeneralInfoField2 =nil;
    GeneralInfolbl =nil, GeneralInfolbl2 =nil, GeneralInfoTextlbl =nil;
    SaveGeneralInfoBtn =nil, CancelGeneralInfoBtn =nil;
    GCompanyName =nil, GStreetAddress =nil, GStreetAddress2 =nil, Gcity =nil, GCountry =nil, GpostalCode =nil, Gphone =nil, GAlternatePhone =nil, GBirthDay =nil, Gstate =nil;
    [GeneCompanyNamesArray  removeAllObjects], [GeneStreetAddressArray  removeAllObjects], [GeneStaddress2Array  removeAllObjects], [GeneCitysArray  removeAllObjects], [GeneCountrysArray  removeAllObjects], [GeneZipcodesArray  removeAllObjects], [GenephoneArray  removeAllObjects], [GeneAleternatePhonesArray  removeAllObjects], [GeneBirthDaysArray  removeAllObjects], [GeneStatesArray  removeAllObjects];
    GeneCompanyNamesArray =nil, GeneStreetAddressArray =nil, GeneStaddress2Array =nil, GeneCitysArray =nil, GeneCountrysArray =nil, GeneZipcodesArray =nil, GenephoneArray =nil, GeneAleternatePhonesArray =nil, GeneBirthDaysArray =nil, GeneStatesArray =nil;
    
    EditGCompanyName =nil, EditGStreetAddress =nil, EditGStreetAddress2 =nil, EditGcity =nil, EditGCountry =nil, EditGpostalCode =nil, EditGphone =nil, EditGAlternatePhone =nil, EditGBirthDay =nil, EditGstate =nil;
    
    
    //ExtendedInfo View
    NSArray *ExtendedInfoViewArray = ExtendedInfoView.subviews;
    for (int i = 0; i<[ExtendedInfoViewArray count]; i++) {
        UIView *vi =[ExtendedInfoViewArray objectAtIndex:i];
        [vi removeFromSuperview];
        vi = nil;
    }
    
    NSArray *ExtendedInfopopUpArray = ExtendedInfopopUp.subviews;
    for (int i = 0; i<[ExtendedInfopopUpArray count]; i++) {
        UIView *vi =[ExtendedInfopopUpArray objectAtIndex:i];
        [vi removeFromSuperview];
        vi = nil;
    }
    [ExtendedInfoView removeFromSuperview],[ExtendedInfopopUp removeFromSuperview];
    ExtendedInfopopUp =nil;
    ExtendedInfoView =nil;
    ExtendedField =nil, ExtendedField2 =nil;
    ExtendedInfolbl =nil, Extendedblbl2 =nil, ExdInfotextlbl =nil;
    CreadidCardListTable =nil;
    SaveExtendedInfoBtn =nil, CancelExtendedInfoBtn =nil;
    CreditcardInfolbl =nil, PersonalInfolbl =nil;
     CreditCardtypesArray =nil;
    CreditCardTypeBtn =nil;
    CreditCardtypelbl =nil;
    CardNo =nil, cardType =nil, Expiration =nil, LicenseId =nil, ExpDate =nil, MPhone =nil, Fax =nil;
    [CardNosArray removeAllObjects];
    [CardtypesArray  removeAllObjects], [ExpirationsArray  removeAllObjects], [LicensesArray  removeAllObjects], [ExpDatesArray  removeAllObjects], [MPhonesArray  removeAllObjects], [FaxesArray  removeAllObjects];
    CardNosArray =nil, CardtypesArray =nil, ExpirationsArray =nil, LicensesArray =nil, ExpDatesArray =nil, MPhonesArray =nil, FaxesArray =nil;
    
    EditCardNo =nil, EditcardType =nil, EditExpiration =nil, EditLicenseId =nil, EditExpDate =nil, EditMPhone =nil, EditFax =nil;
    
    //Notes View
    NotesBackView =nil, NotesView =nil;
    NotesTextView =nil;
    Notestextlbl =nil, EnterNoteslbl =nil;
    SaveNotesBtn =nil, CancelNotesBtn =nil;
    CustomerNotes =nil;
    EditcustomerNotes =nil;
    
    //Shipping view
    NSArray *ShippingInfoViewArray = ShippingInfoView.subviews;
    for (int i = 0; i<[ShippingInfoViewArray count]; i++) {
        UIView *vi =[ShippingInfoViewArray objectAtIndex:i];
        [vi removeFromSuperview];
        vi = nil;
    }
    
    NSArray *ShippingInfoPopUpArray = ShippingInfoPopUp.subviews;
    for (int i = 0; i<[ShippingInfoPopUpArray count]; i++) {
        UIView *vi =[ShippingInfoPopUpArray objectAtIndex:i];
        [vi removeFromSuperview];
        vi = nil;
    }
    [ShippingInfoView removeFromSuperview],[ShippingInfoPopUp removeFromSuperview];
    ShippingInfoPopUp =nil;
    ShippingInfoView =nil;
    ShippingInfoField =nil, ShippingInfoField2 =nil;
    ShippingInfolbl =nil, ShippingInfolbl2 =nil, ShippingInfoTextlbl =nil;
    SaveShippingInfoBtn =nil, CancelShippingInfoBtn =nil;
    ShCompanyName =nil, ShStreetAddress =nil, ShStreetAddress2 =nil, Shcity =nil, ShCountry =nil, ShpostalCode =nil, Shphone =nil, ShAlternatePhone =nil, ShBirthDay =nil, Shstate =nil;
    [ShCompanynamesArray  removeAllObjects], [ShFirstnamesArray  removeAllObjects], [ShlastnamesArray  removeAllObjects], [ShStreetsArray  removeAllObjects], [ShCitysArray  removeAllObjects], [ShCountrysArray  removeAllObjects], [ShPhonenumbersArray  removeAllObjects], [ShExdedArressArray  removeAllObjects], [ShSatesArray  removeAllObjects], [ShZipcodesArray  removeAllObjects];
    ShCompanynamesArray =nil, ShFirstnamesArray =nil, ShlastnamesArray =nil, ShStreetsArray =nil, ShCitysArray =nil, ShCountrysArray =nil, ShPhonenumbersArray =nil, ShExdedArressArray =nil, ShSatesArray =nil, ShZipcodesArray =nil;
    
    
    EditShCompanyName =nil, EditShStreetAddress =nil, EditShStreetAddress2 =nil, EditShcity =nil, EditShCountry =nil, EditShpostalCode =nil, EditShphone =nil, EditShAlternatePhone =nil, EditShBirthDay =nil, EditShstate =nil;
    
    //Stores View
    NSArray *StoresViewArray = StoresView.subviews;
    for (int i = 0; i<[StoresViewArray count]; i++) {
        UIView *vi =[StoresViewArray objectAtIndex:i];
        [vi removeFromSuperview];
        vi = nil;
    }
    
    NSArray *StoresPopupViewArray = StoresPopupView.subviews;
    for (int i = 0; i<[StoresPopupViewArray count]; i++) {
        UIView *vi =[StoresPopupViewArray objectAtIndex:i];
        [vi removeFromSuperview];
        vi = nil;
    }
    [StoresView removeFromSuperview],[StoresPopupView removeFromSuperview];
    StoresPopupView =nil, StoresView =nil;
    Storeslbl =nil, StoresTextlbl =nil;
    StoresListTable =nil, StoresDataTable =nil;
    SavestoresBtn =nil, CancelStoresBtn =nil, StoresBtn =nil, DeleteStoreBtn =nil;
    //Hiestory View
    NSArray *HistoryViewArray = HistoryView.subviews;
    for (int i = 0; i<[HistoryViewArray count]; i++) {
        UIView *vi =[HistoryViewArray objectAtIndex:i];
        [vi removeFromSuperview];
        vi = nil;
    }
    
    NSArray *HistoryPopupViewArray = HistoryPopupView.subviews;
    for (int i = 0; i<[HistoryPopupViewArray count]; i++) {
        UIView *vi =[HistoryPopupViewArray objectAtIndex:i];
        [vi removeFromSuperview];
        vi = nil;
    }
    [HistoryView removeFromSuperview],[HistoryPopupView removeFromSuperview];
    HistoryPopupView =nil, HistoryView =nil;
    Historytextlbl =nil;
    saveHistoryBtn =nil, CancelHistoryBtn =nil;
    [StoreDataArray  removeAllObjects], [SelectedStoredataArray  removeAllObjects];
    [StoredataFromdatabaseArray  removeAllObjects];
    
    StoreDataArray =nil, SelectedStoredataArray =nil;
    StoredataFromdatabaseArray =nil;

     CustomerConnection =nil, GeneralInfoConnection =nil, ExtendedConnection =nil, ShippingConnection =nil, StoreConnection =nil;
     CustomerResponseData =nil, GeneralResponseData =nil, ExtendedResponseData =nil, ShippingResponseData =nil, StoreResponseData =nil;
    
    sationLbl =nil, Timelbl =nil, EmpIdlbl =nil;
    logoBtn =nil;
    
    
    //History
    SalesHistoryTable =nil;
    [itemIDArray  removeAllObjects], [itemNameArray  removeAllObjects], [discountArray  removeAllObjects], [taxArray  removeAllObjects], [yourCostArray  removeAllObjects], [avgArray  removeAllObjects], [quantityArray  removeAllObjects], [dateArray  removeAllObjects], [SnosArray  removeAllObjects];
    itemIDArray =nil, itemNameArray =nil, discountArray =nil, taxArray =nil, yourCostArray =nil, avgArray =nil, quantityArray =nil, dateArray =nil, SnosArray =nil;
    
    selectedCuInvoiceId =nil;
    InvoiceIdsArray =nil;
    
     customerCell =nil;
     customerHistoryCell =nil;
     dataDict =nil;
    [self.view removeFromSuperview];
    self.view=nil;
}
- (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration

{
    if (toInterfaceOrientation==UIInterfaceOrientationLandscapeRight||toInterfaceOrientation==UIInterfaceOrientationLandscapeLeft) {
        isLandScope=YES;
        
    }else
    {
        isLandScope=NO;
    }
    [self updateUI];
}



- (NSUInteger)supportedInterfaceOrientations // iOS 6 autorotation fix
{
    return UIInterfaceOrientationMaskAll;
}


- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    NSArray *viewS = [self.navigationController viewControllers];
    [self.navigationController popToViewController:[viewS objectAtIndex:1] animated:YES];
    [self releaseViews];
    // Dispose of any resources that can be recreated.
}

@end
